From 6fb08ca0ad016cc4d20e320b8ae0aee110dddc8c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 4 Nov 2024 16:38:02 +0700
Subject: <iman> update pengajuan tempo tdk bisa lihat file mobile

---
 .../component/KonfirmasiDokumen.jsx                | 26 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

(limited to 'src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx')

diff --git a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx
index 112b85ef..9b0f1d8f 100644
--- a/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx
+++ b/src/lib/pengajuan-tempo/component/KonfirmasiDokumen.jsx
@@ -145,6 +145,7 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
   useEffect(() => {
     validateDokumen();
   }, [buttonSubmitClick]);
+
   return (
     <>
       {isDesktop && (
@@ -1146,12 +1147,29 @@ const KonfirmasiDokumen = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
               width='100%'
               height='100%'
             /> */}
-            <iframe
-              src={`data:${format};base64,${base64}`}
+            <object
+              data={`data:${format};base64,${base64}`}
+              type={format}
               width='100%'
               height='100%'
-              title='Document'
-            ></iframe>
+              onError={(e) => {
+                // Jika <object> gagal menampilkan PDF, unduh otomatis
+                const link = document.createElement('a');
+                link.href = `data:${format};base64,${base64}`;
+                link.download = 'document.pdf';
+                link.click();
+              }}
+            >
+              PDF tidak dapat ditampilkan.
+              <a
+                href={`data:${format};base64,${base64}`}
+                download='document.pdf'
+              >
+                {' '}
+                Klik <span className='text-red-500'>di sini</span> untuk
+                mengunduh PDF
+              </a>
+            </object>
           </div>
         </BottomPopup>
       )}
-- 
cgit v1.2.3

