From 6fec52b98d1cea2907e1cd34b786240ee8722670 Mon Sep 17 00:00:00 2001 From: kovakmedya Date: Fri, 22 May 2026 01:08:10 +0300 Subject: [PATCH] feat(jobs): confirm-before-download dialog so users see what's happening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Files were grabbed via a plain anchor with the 'download' attribute, so clicking the icon just spawned a silent browser download — nothing in the UI moved, and users (especially labs receiving scans) couldn't tell whether the click registered. Wrapped the download button in a confirm dialog that mirrors the existing delete flow: title 'Dosya indirilsin mi?', filename + size in the body, Vazgeç / İndir buttons. The 'İndir' button programmatically clicks a hidden anchor pointing at the /api/.../download proxy and surfaces a 'İndirme başladı.' toast with the filename so there's a clear visual ack even before the OS download tray pops. --- .../[jobId]/components/job-files-panel.tsx | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/app/(dashboard)/jobs/[jobId]/components/job-files-panel.tsx b/src/app/(dashboard)/jobs/[jobId]/components/job-files-panel.tsx index 2b99eeb..0342c70 100644 --- a/src/app/(dashboard)/jobs/[jobId]/components/job-files-panel.tsx +++ b/src/app/(dashboard)/jobs/[jobId]/components/job-files-panel.tsx @@ -242,6 +242,7 @@ function FileRow({ file }: { file: JobFileWithUrl }) { ); const [, startTransition] = useTransition(); const [open, setOpen] = useState(false); + const [downloadOpen, setDownloadOpen] = useState(false); useEffect(() => { if (state.ok) { @@ -252,6 +253,20 @@ function FileRow({ file }: { file: JobFileWithUrl }) { } }, [state]); + function triggerDownload() { + // Use a programmatic anchor click — the server route streams the file + // with Content-Disposition: attachment, so the browser hands it straight + // to the download manager. Toast confirms it left our side. + const a = document.createElement("a"); + a.href = file.url; + a.download = file.name; + document.body.appendChild(a); + a.click(); + a.remove(); + setDownloadOpen(false); + toast.success("İndirme başladı.", { description: file.name }); + } + return (
  • {kindIcon(file.kind)} @@ -264,11 +279,31 @@ function FileRow({ file }: { file: JobFileWithUrl }) { {JOB_FILE_KIND_LABELS[file.kind] ?? file.kind} - + + + + Dosya indirilsin mi? + + {file.name} + · {formatSize(file.size)} + + + + + + + + + +