import { useCallback, useEffect, useRef, useState } from 'react'; import FileUploadInput from './FileUploadInput'; import InitiateButton from './InitiateButton'; interface UploadSectionProps { onAnalyze: (file: File) => void; onBack: () => void; } function fmtBytes(b: number) { if (b < 1024) return b + ' B'; if (b < 1048576) return (b / 1024).toFixed(1) + ' KB'; return (b / 1048576).toFixed(1) + ' MB'; } export default function UploadSection({ onAnalyze, onBack }: UploadSectionProps) { const [file, setFile] = useState(null); const [dragging, setDragging] = useState(false); const [time, setTime] = useState('--:--:--'); const inputRef = useRef(null); useEffect(() => { const t = setInterval(() => { setTime(new Date().toLocaleTimeString('en-US', { hour12: false })); }, 1000); return () => clearInterval(t); }, []); const applyFile = useCallback((f: File) => { if (!f.type.startsWith('video/')) return; setFile(f); }, []); const onDrop = useCallback((e: React.DragEvent) => { e.preventDefault(); setDragging(false); const f = e.dataTransfer.files[0]; if (f) applyFile(f); }, [applyFile]); return (
{/* Header */}

SECURE INGEST PORTAL

Awaiting encrypted payload via protocol AX-9.

{/* Drop zone outer */}
{/* Drop zone inner */}
{/* clicks handled by FileUploadInput */}} onDragOver={e => { e.preventDefault(); setDragging(true); }} onDragLeave={() => setDragging(false)} onDrop={onDrop} className="p-10 flex flex-col items-center justify-center border-2 border-dashed m-4 rounded-lg transition-all duration-300 cursor-pointer min-h-[300px]" style={{ borderColor: dragging ? 'rgba(168,85,247,0.7)' : 'rgba(88,28,135,0.4)', background: dragging ? 'rgba(168,85,247,0.06)' : 'rgba(20,10,35,0.3)', boxShadow: dragging ? '0 0 40px rgba(168,85,247,0.12) inset' : 'none', }} onMouseEnter={e => { if (!dragging) { (e.currentTarget as HTMLDivElement).style.borderColor = 'rgba(168,85,247,0.5)'; (e.currentTarget as HTMLDivElement).style.background = 'rgba(168,85,247,0.04)'; } }} onMouseLeave={e => { if (!dragging) { (e.currentTarget as HTMLDivElement).style.borderColor = 'rgba(88,28,135,0.4)'; (e.currentTarget as HTMLDivElement).style.background = 'rgba(20,10,35,0.3)'; } }} > {!file ? (
{/* Animated folder upload widget */}

INITIALIZE UPLOAD

Drag and drop your video file here, or use the button above.

ACCEPTED: MP4 · AVI · MOV · MKV · WebM
) : (
video_file

{file.name}

{fmtBytes(file.size)}

)}
{/* Hidden input — used only by drag-and-drop path */} e.target.files?.[0] && applyFile(e.target.files[0])} /> {/* Initiate analysis button */} file && onAnalyze(file)} disabled={!file} /> {/* Active queue */}

ACTIVE QUEUE

SYS_TIME: {time}
{file ? (
video_file {file.name} QUEUED
) : (
inbox No payload queued. Awaiting upload.
)}
{/* Back */}
); }