From 3b10745f49c41b90cc5d81c2e80ae03e1dbd5c06 Mon Sep 17 00:00:00 2001 From: wartana Date: Thu, 22 Jan 2026 16:17:14 +0800 Subject: [PATCH] Add SweetAlert2 availability check and fallback to standard confirm dialog for logout --- index.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 0bff4aa..f0af36c 100644 --- a/index.php +++ b/index.php @@ -802,20 +802,29 @@ function confirmLogout(event) { event.preventDefault(); var logoutUrl = event.currentTarget.href; - Swal.fire({ - title: 'Konfirmasi Logout', - text: 'Apakah Anda yakin akan keluar dari sistem?', - icon: 'question', - showCancelButton: true, - confirmButtonColor: '#3085d6', - cancelButtonColor: '#d33', - confirmButtonText: 'Ya, Keluar', - cancelButtonText: 'Batal' - }).then((result) => { - if (result.isConfirmed) { + + // Check if SweetAlert2 is available + if (typeof Swal !== 'undefined' && Swal.fire) { + Swal.fire({ + title: 'Konfirmasi Logout', + text: 'Apakah Anda yakin akan keluar dari sistem?', + icon: 'question', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Ya, Keluar', + cancelButtonText: 'Batal' + }).then((result) => { + if (result.isConfirmed) { + window.location.href = logoutUrl; + } + }); + } else { + // Fallback to standard confirm dialog + if (confirm('Apakah Anda yakin akan keluar dari sistem?')) { window.location.href = logoutUrl; } - }); + } } function zoomIn() {