import { useState } from "react"; import { useFileStore } from "@/stores/file-store"; import { useToolProcessor } from "@/hooks/use-tool-processor"; import { Download, RotateCcw, RotateCw, FlipHorizontal, FlipVertical, } from "lucide-react"; import { ProgressCard } from "@/components/common/progress-card"; export function RotateSettings() { const { files } = useFileStore(); const { processFiles, processing, error, downloadUrl, originalSize, processedSize, progress } = useToolProcessor("rotate"); const [angle, setAngle] = useState(0); const [flipH, setFlipH] = useState(false); const [flipV, setFlipV] = useState(false); const rotateLeft = () => setAngle((a) => (a - 90 + 360) % 360); const rotateRight = () => setAngle((a) => (a + 90) % 360); const handleProcess = () => { processFiles(files, { angle, horizontal: flipH, vertical: flipV, }); }; const hasFile = files.length > 0; const hasChanges = angle !== 0 || flipH || flipV; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (hasFile && hasChanges && !processing) handleProcess(); }; return (
{/* Quick rotate buttons */}
{/* Angle slider */}
{angle} deg
setAngle(Number(e.target.value))} className="w-full mt-1" />
{/* Flip buttons */}
{/* Error */} {error &&

{error}

} {/* Size info */} {originalSize != null && processedSize != null && (

Original: {(originalSize / 1024).toFixed(1)} KB

Processed: {(processedSize / 1024).toFixed(1)} KB

)} {/* Process */} {processing ? ( ) : ( )} {/* Download */} {downloadUrl && ( Download )} ); }