import { useState } from "react"; import { useFileStore } from "@/stores/file-store"; import { useToolProcessor } from "@/hooks/use-tool-processor"; import { Download } from "lucide-react"; import { ProgressCard } from "@/components/common/progress-card"; const ASPECT_PRESETS = [ { label: "1:1", w: 1, h: 1 }, { label: "4:3", w: 4, h: 3 }, { label: "16:9", w: 16, h: 9 }, { label: "2:3", w: 2, h: 3 }, { label: "4:5", w: 4, h: 5 }, ]; export function CropSettings() { const { files } = useFileStore(); const { processFiles, processing, error, downloadUrl, originalSize, processedSize, progress } = useToolProcessor("crop"); const [left, setLeft] = useState("0"); const [top, setTop] = useState("0"); const [width, setWidth] = useState(""); const [height, setHeight] = useState(""); const applyAspect = (w: number, h: number) => { // If width is set, calculate height from aspect ratio const currentW = Number(width); if (currentW > 0) { setHeight(String(Math.round((currentW * h) / w))); } }; const handleProcess = () => { processFiles(files, { left: Number(left), top: Number(top), width: Number(width), height: Number(height), }); }; const hasFile = files.length > 0; const hasSize = Number(width) > 0 && Number(height) > 0; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (hasFile && hasSize && !processing) handleProcess(); }; return (
); }