import { useState } from "react"; import { useNavigate } from "react-router-dom"; import { motion, AnimatePresence } from "framer-motion"; import { Upload, Plus, FileText, Music, X, Check, AlertCircle, } from "lucide-react"; import toast from "react-hot-toast"; function QuickActions() { const navigate = useNavigate(); const [showUploadModal, setShowUploadModal] = useState(false); const [dragActive, setDragActive] = useState(false); const [uploading, setUploading] = useState(false); const [uploadedFile, setUploadedFile] = useState(null); const handleDrag = (e) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }; const handleDrop = (e) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files && e.dataTransfer.files[0]) { handleFile(e.dataTransfer.files[0]); } }; const handleFileInput = (e) => { if (e.target.files && e.target.files[0]) { handleFile(e.target.files[0]); } }; const handleFile = async (file) => { // Check file type const validTypes = ["text/plain", "application/pdf", ".docx", ".doc"]; const isValid = validTypes.some( (type) => file.type.includes(type) || file.name.endsWith(type), ); if ( !isValid && !file.name.endsWith(".txt") && !file.name.endsWith(".pdf") ) { toast.error("Please upload a .txt, .pdf, or .docx file"); return; } setUploadedFile(file); setUploading(true); // Simulate upload await new Promise((r) => setTimeout(r, 1500)); setUploading(false); toast.success("File uploaded successfully!"); }; const handleProcessFile = () => { // Navigate to song editor with parsed content setShowUploadModal(false); setUploadedFile(null); navigate("/song/new"); toast.success("Creating new song from lyrics..."); }; return ( <>
Import lyrics from .txt, .pdf, or .docx files
Start from scratch with our chord editor
Drag and drop your file here, or{" "}
Supports .txt, .pdf, .docx files
{uploadedFile.name}
{uploading ? "Uploading..." : "Ready to process"}
We'll try to detect sections (Verse, Chorus, etc.) and existing chord notations automatically.