import { useRef, useState } from "react"; import Button from "../../../components/Button"; export default function UploadArea( { setVideoUrl, setSrtUrl }: { setVideoUrl: (url: string | null) => void; setSrtUrl: (url: string | null) => void; } ) { const inputRef = useRef(null); const [videoFile, setVideoFile] = useState(null); const [SrtFile, setSrtFile] = useState(null); const uploadVideo = () => { const input = inputRef.current; if (input) { input.setAttribute('accept', 'video/*'); input.click(); input.onchange = () => { const file = input.files?.[0]; if (file) { setVideoFile(file); setVideoUrl(URL.createObjectURL(file)); } }; } } const uploadSRT = () => { const input = inputRef.current; if (input) { input.setAttribute('accept', '.srt'); input.click(); input.onchange = () => { const file = input.files?.[0]; if (file) { setSrtFile(file); setSrtUrl(URL.createObjectURL(file)); } }; } } return (
File Name Type Size Actions
{videoFile?.name} Video {videoFile ? (videoFile.size / 1024 / 1024).toFixed(2) + 'MB' : null}
{SrtFile?.name} SRT {SrtFile ? (SrtFile.size / 1024 / 1024).toFixed(2) + 'MB' : null}
) }