+
-
-
-
-
- | No |
- Nama Offtaker |
- Kabupaten |
- Kecamatan |
- Status |
- Aksi |
-
-
-
-
+
+
+
+
+
+ | No |
+ Nama Offtaker |
+ Kabupaten |
+ Kecamatan |
+ Status |
+ Aksi |
+
+
+
+
+
@@ -73,7 +161,7 @@
$(document).ready(function () {
table = new DataTable('#example', {
- ajax: '/Main/DataNasabah/Table',
+ ajax: '/Main/DataOfftaker/Table',
scrollX: true,
autoWidth: false,
initComplete: function () {
@@ -89,23 +177,97 @@
]
});
- table.on("click", ".delete", function (e) {
+ // Delete button handler
+ $('#example').on('click', '.btn-circle.btn-error', function (e) {
e.preventDefault();
- let url = $(this).data("url");
- swal.fire({
- title: "Apakah anda yakin?",
+ Swal.fire({
+ title: 'Apakah anda yakin?',
text: "Data yang dihapus tidak dapat dikembalikan lagi",
- icon: "question",
+ icon: 'warning',
showCancelButton: true,
- confirmButtonText: "Ya, Hapus",
- cancelButtonText: "Batal",
+ confirmButtonText: 'Ya, Hapus',
+ cancelButtonText: 'Batal',
buttonsStyling: false,
customClass: {
- confirmButton: "btn btn-error text-white",
- cancelButton: "btn btn-link no-underline text-gray-500",
+ 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((result) => {
+ if (result.isConfirmed) {
+ // TODO: Implement actual delete API call
+ Swal.fire({
+ title: 'Terhapus!',
+ text: 'Data berhasil dihapus.',
+ icon: 'success',
+ confirmButtonText: 'OK',
+ buttonsStyling: false,
+ customClass: {
+ confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
+ },
+ }).then(() => {
+ // Reload table
+ table.ajax.reload();
+ });
+ }
});
});
+
+ // Edit button handler
+ $('#example').on('click', '.btn-circle.btn-warning', function (e) {
+ e.preventDefault();
+
+ // Get row data
+ var row = table.row($(this).parents('tr')).data();
+
+ // Set edit mode
+ $('#edit_mode').val('true');
+ $('#modal_title').text('Edit Data Offtaker');
+
+ // Populate form with row data
+ $('#nama').val(row.nama);
+ $('#kabupaten').val(row.kabupaten);
+ $('#kecamatan').val(row.kecamatan);
+
+ // Extract status from HTML badge
+ var statusText = $(row.status).text().trim();
+ $('#status').val(statusText);
+
+ // Open modal
+ modal_tambah.showModal();
+ });
});
-
\ No newline at end of file
+
+ function closeModal() {
+ // Reset form
+ $('#formTambah')[0].reset();
+ $('#edit_mode').val('false');
+ $('#modal_title').text('Tambah Data Offtaker');
+
+ // Close modal
+ modal_tambah.close();
+ }
+
+ function submitForm(e) {
+ e.preventDefault();
+
+ var isEditMode = $('#edit_mode').val() === 'true';
+
+ // TODO: Implement form submission logic
+ Swal.fire({
+ title: 'Berhasil!',
+ text: isEditMode ? 'Data berhasil diperbarui' : 'Data berhasil ditambahkan',
+ icon: 'success',
+ confirmButtonText: 'OK',
+ buttonsStyling: false,
+ customClass: {
+ confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
+ },
+ }).then(() => {
+ closeModal();
+
+ // Reload table
+ table.ajax.reload();
+ });
+ }
+
diff --git a/Views/Main/Maggot/Index.cshtml b/Views/Main/Maggot/Index.cshtml
index 80025b9..79a8ed7 100644
--- a/Views/Main/Maggot/Index.cshtml
+++ b/Views/Main/Maggot/Index.cshtml
@@ -20,8 +20,9 @@
+
+