From da5c7c1cfad82471684f34cdaa7a02bb56063afd Mon Sep 17 00:00:00 2001 From: seriouselly Date: Tue, 16 Jun 2026 19:12:44 +0700 Subject: [PATCH] feat(scan): implement drag and drop functionality for image upload - Add `onDragOver`, `onDragLeave`, and `onDrop` event handlers to capture dragged files. - Introduce `isDragging` state to provide visual UI feedback when a file is hovered over the drop zone. - Wire the dropped file data to the existing `handleFile` processing logic. --- apps/web/src/pages/scan-page.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/web/src/pages/scan-page.tsx b/apps/web/src/pages/scan-page.tsx index 838a509..764ad16 100644 --- a/apps/web/src/pages/scan-page.tsx +++ b/apps/web/src/pages/scan-page.tsx @@ -33,6 +33,7 @@ export function ScanPage() { const imageRef = useRef(null); const navigate = useNavigate(); const queryClient = useQueryClient(); + const [isDragging, setIsDragging] = useState(false); // Camera mode state const [useCamera, setUseCamera] = useState(false); @@ -164,8 +165,25 @@ export function ScanPage() { ) : ( <>
inputRef.current?.click()} + onDragOver={(e) => { + e.preventDefault(); + setIsDragging(true); + }} + onDragLeave={() => setIsDragging(false)} + onDrop={(e) => { + e.preventDefault(); + setIsDragging(false); + const droppedFile = e.dataTransfer.files?.[0]; + if (droppedFile) { + handleFile(droppedFile); + } + }} >