import { Mic, Pause, Play, Upload } from 'lucide-react'; import { useRef, useState } from 'react'; import { Button } from '@/components/ui/button'; import { FormControl, FormItem, FormMessage } from '@/components/ui/form'; interface AudioSampleUploadProps { file: File | null | undefined; onFileChange: (file: File | undefined) => void; onTranscribe: () => void; onPlayPause: () => void; isPlaying: boolean; isValidating?: boolean; isTranscribing?: boolean; isDisabled?: boolean; fieldName: string; } export function AudioSampleUpload({ file, onFileChange, onTranscribe, onPlayPause, isPlaying, isValidating = false, isTranscribing = false, isDisabled = false, fieldName, }: AudioSampleUploadProps) { const [isDragging, setIsDragging] = useState(false); const fileInputRef = useRef(null); return (
{ const selectedFile = e.target.files?.[0]; if (selectedFile) { onFileChange(selectedFile); } else { onFileChange(undefined); } }} className="hidden" />
{ e.preventDefault(); setIsDragging(true); }} onDragLeave={(e) => { e.preventDefault(); setIsDragging(false); }} onDrop={(e) => { e.preventDefault(); setIsDragging(false); const droppedFile = e.dataTransfer.files?.[0]; if (droppedFile?.type.startsWith('audio/')) { onFileChange(droppedFile); } }} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fileInputRef.current?.click(); } }} className={`flex flex-col items-center justify-center gap-4 p-4 border-2 rounded-lg transition-colors min-h-[180px] ${ file ? 'border-primary bg-primary/5' : isDragging ? 'border-primary bg-primary/5' : 'border-dashed border-muted-foreground/25 hover:border-muted-foreground/50' }`} > {!file ? ( <>

Click to choose a file or drag and drop. Maximum duration: 30 seconds.

) : ( <>
File uploaded

File: {file.name}

)}
); }