import { Sparkles, Upload } from 'lucide-react'; import { useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { FloatingGenerateBox } from '@/components/Generation/FloatingGenerateBox'; import { HistoryTable } from '@/components/History/HistoryTable'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { useToast } from '@/components/ui/use-toast'; import { ProfileList } from '@/components/VoiceProfiles/ProfileList'; import { useImportProfile } from '@/lib/hooks/useProfiles'; import { cn } from '@/lib/utils/cn'; import { usePlayerStore } from '@/stores/playerStore'; import { useUIStore } from '@/stores/uiStore'; export function MainEditor() { const { t } = useTranslation(); const audioUrl = usePlayerStore((state) => state.audioUrl); const isPlayerVisible = !!audioUrl; const scrollRef = useRef(null); const setDialogOpen = useUIStore((state) => state.setProfileDialogOpen); const importProfile = useImportProfile(); const fileInputRef = useRef(null); const [importDialogOpen, setImportDialogOpen] = useState(false); const [selectedFile, setSelectedFile] = useState(null); const { toast } = useToast(); const handleImportClick = () => { fileInputRef.current?.click(); }; const handleFileChange = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { if (!file.name.endsWith('.voicebox.zip')) { toast({ title: t('main.import.invalidTitle'), description: t('main.import.invalidDescription'), variant: 'destructive', }); return; } setSelectedFile(file); setImportDialogOpen(true); } }; const handleImportConfirm = () => { if (selectedFile) { importProfile.mutate(selectedFile, { onSuccess: () => { setImportDialogOpen(false); setSelectedFile(null); if (fileInputRef.current) { fileInputRef.current.value = ''; } toast({ title: t('main.import.successTitle'), description: t('main.import.successDescription'), }); }, onError: (error) => { toast({ title: t('main.import.failedTitle'), description: error.message, variant: 'destructive', }); }, }); } }; return (

Voicebox

{t('main.import.dialogTitle')} {t('main.import.dialogDescription', { name: selectedFile?.name })}
); }