From a44a39565e2b2fc1f8e11e8cf01cecab21b86cff Mon Sep 17 00:00:00 2001 From: Kevin Hendrawan Date: Tue, 18 Nov 2025 19:41:51 +0700 Subject: [PATCH] feat(validation button): add dialog approval and reason modal --- Views/Main/DataBankSampah/Index.cshtml | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Views/Main/DataBankSampah/Index.cshtml b/Views/Main/DataBankSampah/Index.cshtml index f2ab3a6..6451778 100644 --- a/Views/Main/DataBankSampah/Index.cshtml +++ b/Views/Main/DataBankSampah/Index.cshtml @@ -200,6 +200,67 @@ }); }); + $('#example').on('click', '.btn-circle.btn-success', function (e) { + Swal.fire({ + title: 'Validasi Data Bank Sampah', + text: 'Silakan pilih tindakan untuk data bank sampah yang sedang diperiksa.', + icon: 'question', + showCancelButton: true, + showDenyButton: true, + confirmButtonText: 'Setujui Data', + denyButtonText: 'Tolak Data', + cancelButtonText: 'Batal', + buttonsStyling: false, + customClass: { + confirmButton: 'btn bg-bank-sampah-primary-500 rounded-full text-white', + denyButton: 'btn bg-red-500 text-white hover:bg-red-600 px-4 py-2 rounded-full mr-2', + cancelButton: 'btn bg-white text-gray-500 hover:bg-gray-50 px-4 py-2 rounded-full border border-gray-300' + }, + }).then((result) => { + + // APPROVE + if (result.isConfirmed) { + Swal.fire({ + icon: 'success', + title: 'Sukses!', + text: 'Data berhasil di setujui.', + timer: 1000, + showConfirmButton: false + }); + } + + // REJECT → open reason form + else if (result.isDenied) { + Swal.fire({ + title: 'Alasan Penolakan', + input: 'textarea', + inputPlaceholder: 'Masukkan keterangan mengapa data ditolak...', + inputAttributes: { + 'aria-label': 'Reason' + }, + showCancelButton: true, + confirmButtonText: 'Ya, Tolak', + cancelButtonText: 'Batal', + buttonsStyling: false, + customClass: { + confirmButton: 'btn bg-red-500 text-white hover:bg-red-600 px-4 py-2 rounded-full mr-2', + cancelButton: 'btn bg-white text-gray-500 hover:bg-gray-50 px-4 py-2 rounded-full border border-gray-300', + }, + }).then((reasonResult) => { + if (reasonResult.isConfirmed) { + Swal.fire({ + icon: 'success', + title: 'Sukses!', + text: 'Data berhasil di tolak.', + timer: 1000, + showConfirmButton: false + }); + } + }); + } + }); + }); + function closeModal() { // Reset form $('#formTambah')[0].reset();