From 60b29aa7de3368fc673deec5e942a87c4720291b Mon Sep 17 00:00:00 2001 From: "nabijonovdavronbek619@gmail.com" Date: Thu, 2 Apr 2026 21:27:55 +0500 Subject: [PATCH] sertificate downloaded added --- src/widgets/detail/sertifikat.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/widgets/detail/sertifikat.tsx b/src/widgets/detail/sertifikat.tsx index f913e67..d017839 100644 --- a/src/widgets/detail/sertifikat.tsx +++ b/src/widgets/detail/sertifikat.tsx @@ -12,17 +12,28 @@ export default function Sertifikat({ document_id }: { document_id: number }) { const handleClick = async () => { setLoading(true); try { - const url = `${baseUrl}/documents/${document_id}/certificate/`; + const url = `${baseUrl}/shared/certificate/${document_id}/pdf/`; const res = await fetch(url); const blob = await res.blob(); const objectUrl = URL.createObjectURL(blob); - window.open(objectUrl, '_blank'); + + // ✅ window.open o'rniga tag bilan download + const a = document.createElement('a'); + a.href = objectUrl; + a.download = `certificate-${document_id}.pdf`; + a.click(); + URL.revokeObjectURL(objectUrl); } finally { setLoading(false); } }; + // const handleClick = () => { + // const url = `${baseUrl}/documents/${document_id}/pdf/`; + // window.open(url, '_blank'); + // }; + return (