MCPcopy Create free account
hub / github.com/debpalash/VoiceStudio / BatchAddDialog

Function BatchAddDialog

frontend/src/components/BatchAddDialog.jsx:14–208  ·  view source on GitHub ↗
({
  open,
  onClose,
  profiles = [],
  onEnqueue, // async (files, settings) => void
})

Source from the content-addressed store, hash-verified

12 * Each file is POSTed as a separate job to the batch endpoint.
13 */
14export default function BatchAddDialog({
15 open,
16 onClose,
17 profiles = [],
18 onEnqueue, // async (files, settings) => void
19}) {
20 const { t } = useTranslation();
21 const [files, setFiles] = useState([]);
22 const [langs, setLangs] = useState([{ lang: 'Spanish', code: 'es' }]);
23 const [voiceId, setVoiceId] = useState('');
24 const [preserveBg, setPreserveBg] = useState(true);
25 const [submitting, setSubmitting] = useState(false);
26 const [dragOver, setDragOver] = useState(false);
27 const fileInputRef = useRef(null);
28
29 const handleDrop = useCallback((e) => {
30 e.preventDefault();
31 const dropped = Array.from(e.dataTransfer.files).filter((f) => f.type.startsWith('video/'));
32 if (dropped.length) setFiles((prev) => [...prev, ...dropped]);
33 }, []);
34
35 const removeFile = (idx) => {
36 setFiles((prev) => prev.filter((_, i) => i !== idx));
37 };
38
39 const handleSubmit = async () => {
40 if (!files.length || !langs.length) return;
41 setSubmitting(true);
42 try {
43 await onEnqueue?.(files, { langs, voiceId, preserveBg });
44 setFiles([]);
45 onClose?.();
46 } finally {
47 setSubmitting(false);
48 }
49 };
50
51 return (
52 <Dialog
53 open={open}
54 onClose={onClose}
55 size="md"
56 title={
57 <span className="inline-flex items-center gap-[6px]">
58 <Plus size={14} /> {t('batch.add_to_queue_title')}
59 </span>
60 }
61 footer={
62 <>
63 <span className="flex-1 font-mono text-[0.68rem] text-[var(--chrome-fg-dim)]">
64 {files.length > 0 && langs.length > 0
65 ? t('batch.estimate', {
66 videos: files.length,
67 langs: langs.length,
68 jobs: files.length * langs.length,
69 })
70 : t('batch.select_files_langs')}
71 </span>

Callers

nothing calls this directly

Calls 4

handleDropFunction · 0.85
removeFileFunction · 0.85
tFunction · 0.50
filterMethod · 0.45

Tested by

no test coverage detected