()
| 21 | import { useUIStore } from '@/stores/uiStore'; |
| 22 | |
| 23 | export function MainEditor() { |
| 24 | const { t } = useTranslation(); |
| 25 | const audioUrl = usePlayerStore((state) => state.audioUrl); |
| 26 | const isPlayerVisible = !!audioUrl; |
| 27 | const scrollRef = useRef<HTMLDivElement>(null); |
| 28 | const setDialogOpen = useUIStore((state) => state.setProfileDialogOpen); |
| 29 | const importProfile = useImportProfile(); |
| 30 | const fileInputRef = useRef<HTMLInputElement>(null); |
| 31 | const [importDialogOpen, setImportDialogOpen] = useState(false); |
| 32 | const [selectedFile, setSelectedFile] = useState<File | null>(null); |
| 33 | const { toast } = useToast(); |
| 34 | |
| 35 | const handleImportClick = () => { |
| 36 | fileInputRef.current?.click(); |
| 37 | }; |
| 38 | |
| 39 | const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
| 40 | const file = e.target.files?.[0]; |
| 41 | if (file) { |
| 42 | if (!file.name.endsWith('.voicebox.zip')) { |
| 43 | toast({ |
| 44 | title: t('main.import.invalidTitle'), |
| 45 | description: t('main.import.invalidDescription'), |
| 46 | variant: 'destructive', |
| 47 | }); |
| 48 | return; |
| 49 | } |
| 50 | setSelectedFile(file); |
| 51 | setImportDialogOpen(true); |
| 52 | } |
| 53 | }; |
| 54 | |
| 55 | const handleImportConfirm = () => { |
| 56 | if (selectedFile) { |
| 57 | importProfile.mutate(selectedFile, { |
| 58 | onSuccess: () => { |
| 59 | setImportDialogOpen(false); |
| 60 | setSelectedFile(null); |
| 61 | if (fileInputRef.current) { |
| 62 | fileInputRef.current.value = ''; |
| 63 | } |
| 64 | toast({ |
| 65 | title: t('main.import.successTitle'), |
| 66 | description: t('main.import.successDescription'), |
| 67 | }); |
| 68 | }, |
| 69 | onError: (error) => { |
| 70 | toast({ |
| 71 | title: t('main.import.failedTitle'), |
| 72 | description: error.message, |
| 73 | variant: 'destructive', |
| 74 | }); |
| 75 | }, |
| 76 | }); |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | return ( |
nothing calls this directly
no test coverage detected