import { useState } from "react"; import { ProgressCard } from "@/components/common/progress-card"; import { useTranslation } from "@/contexts/i18n-context"; import { useToolProcessor } from "@/hooks/use-tool-processor"; import { format } from "@/lib/format"; import { useFileStore } from "@/stores/file-store"; type Preset = "custom" | "2160p" | "1440p" | "1080p" | "720p" | "480p" | "360p"; export function ResizeVideoSettings() { const { t } = useTranslation(); const s = t.toolSettings["resize-video"]; const { files } = useFileStore(); const { processFiles, processAllFiles, processing, error, progress } = useToolProcessor("resize-video"); const [preset, setPreset] = useState("custom"); const [width, setWidth] = useState(""); const [height, setHeight] = useState(""); const hasFile = files.length > 0; const hasMultiple = files.length > 1; const isCustom = preset === "custom"; const customValid = !isCustom || width !== "" || height !== ""; const handleProcess = () => { const settings: Record = { preset }; if (isCustom) { if (width !== "") settings.width = width; if (height !== "") settings.height = height; } if (hasMultiple) { processAllFiles(files, settings); } else { processFiles(files, settings); } }; return (
{isCustom && ( <>
setWidth(e.target.value === "" ? "" : Number(e.target.value))} className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground" />
setHeight(e.target.value === "" ? "" : Number(e.target.value))} className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground" />

{s.hint}

)} {error &&

{error}

} {processing ? ( ) : ( )}
); }