diff --git a/resources/js/components/modal/delete-confirmation.tsx b/resources/js/components/modal/delete-confirmation.tsx
new file mode 100644
index 0000000..ae6de14
--- /dev/null
+++ b/resources/js/components/modal/delete-confirmation.tsx
@@ -0,0 +1,59 @@
+import { Trash2, X } from 'lucide-react';
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogMedia,
+ AlertDialogTitle,
+} from "@/components/ui/alert-dialog";
+import React from 'react';
+
+interface DeleteConfirmationProps {
+ isOpen: boolean;
+ onOpenChange: (open: boolean) => void;
+ title?: React.ReactNode;
+ description?: React.ReactNode;
+ onDelete: () => void;
+ cancelText?: string;
+ deleteText?: string;
+}
+
+export function DeleteConfirmation({
+ isOpen,
+ onOpenChange,
+ title = "Hapus item?",
+ description = "Tindakan ini tidak dapat dibatalkan. Item ini akan dihapus secara permanen.",
+ onDelete,
+ cancelText = "Batal",
+ deleteText = "Hapus",
+}: DeleteConfirmationProps) {
+ return (
+
+
+
+
+
+
+ {title}
+
+ {description}
+
+
+
+
+
+ {cancelText}
+
+
+
+ {deleteText}
+
+
+
+
+ );
+}
diff --git a/resources/js/pages/admin/finance/expense/index.tsx b/resources/js/pages/admin/finance/expense/index.tsx
index fdc8182..947f20d 100644
--- a/resources/js/pages/admin/finance/expense/index.tsx
+++ b/resources/js/pages/admin/finance/expense/index.tsx
@@ -20,6 +20,7 @@ import { Dialog, DialogContent } from "@/components/ui/dialog"
import { useExpenseIndex } from './hooks/use-expense-index';
import { getColumns } from './partials/columns';
import { ExpenseFormModal } from './partials/expense-form-modal';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
export default function ExpenseIndex({ expenses }: { expenses: Expense[] }) {
const {
@@ -108,58 +109,30 @@ export default function ExpenseIndex({ expenses }: { expenses: Expense[] }) {
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus pengeluaran?
-
- Tindakan ini tidak dapat dibatalkan. Pengeluaran {expenseToDelete?.name} akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Pengeluaran {expenseToDelete?.name} akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} pengeluaran?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}
diff --git a/resources/js/pages/admin/finance/payroll/index.tsx b/resources/js/pages/admin/finance/payroll/index.tsx
index 5b4b927..3542948 100644
--- a/resources/js/pages/admin/finance/payroll/index.tsx
+++ b/resources/js/pages/admin/finance/payroll/index.tsx
@@ -20,6 +20,7 @@ import { usePayrollIndex } from './hooks/use-payroll-index';
import { Badge } from '@/components/ui/badge';
import { getColumns } from './partials/columns';
import { PayrollFormModal } from './partials/payroll-form-modal';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
export default function PayrollIndex({
payrolls,
@@ -147,58 +148,30 @@ export default function PayrollIndex({
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus data penggajian?
-
- Tindakan ini tidak dapat dibatalkan. Data penggajian untuk {payrollToDelete?.user?.name} periode {payrollToDelete?.period_month} akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Penggajian {payrollToDelete?.period_month_formatted} akan dihapus secara permanen dan stok akan dikembalikan.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} data penggajian?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}
diff --git a/resources/js/pages/admin/manage/order/index.tsx b/resources/js/pages/admin/manage/order/index.tsx
index 2bb1e2a..7083ed8 100644
--- a/resources/js/pages/admin/manage/order/index.tsx
+++ b/resources/js/pages/admin/manage/order/index.tsx
@@ -38,6 +38,7 @@ import { EscPosEncoder } from '@/lib/esc-pos-encoder';
import { format } from 'date-fns';
import { id } from 'date-fns/locale';
import { toast } from 'sonner';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
export default function OrderIndex({ orders }: { orders: Order[] }) {
const {
@@ -215,58 +216,30 @@ export default function OrderIndex({ orders }: { orders: Order[] }) {
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus pesanan?
-
- Tindakan ini tidak dapat dibatalkan. Data pesanan dengan nomor invoice {orderToDelete?.invoice_number} akan dihapus secara permanen dan stok akan dikembalikan.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Pesanan {orderToDelete?.invoice_number} akan dihapus secara permanen dan stok akan dikembalikan.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} data pesanan?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} pesanan yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}
diff --git a/resources/js/pages/admin/manage/purchase/index.tsx b/resources/js/pages/admin/manage/purchase/index.tsx
index 5273c88..3bd5d14 100644
--- a/resources/js/pages/admin/manage/purchase/index.tsx
+++ b/resources/js/pages/admin/manage/purchase/index.tsx
@@ -21,6 +21,8 @@ import {
import purchaseRoutes from '@/routes/purchase';
import { usePurchaseIndex } from './hooks/use-purchase-index';
import { getColumns } from './partials/columns';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
+import { formatDate } from '@/lib/formatters';
export default function PurchaseIndex({ purchases }: { purchases: Purchase[] }) {
const {
@@ -79,47 +81,32 @@ export default function PurchaseIndex({ purchases }: { purchases: Purchase[] })
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus data belanja?
-
- Tindakan ini tidak dapat dibatalkan. Data belanja tanggal {purchaseToDelete && format(new Date(purchaseToDelete.purchase_date), 'dd MMMM yyyy', { locale: id })} akan dihapus secara permanen.
-
-
-
- Batal
- Hapus
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Belanja {purchaseToDelete?.purchase_date
+ ? formatDate(purchaseToDelete?.purchase_date)
+ : purchaseToDelete?.note || '-'} akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} data belanja?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
-
-
-
- Batal
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}
diff --git a/resources/js/pages/admin/master/category/index.tsx b/resources/js/pages/admin/master/category/index.tsx
index 1e0cd97..35207db 100644
--- a/resources/js/pages/admin/master/category/index.tsx
+++ b/resources/js/pages/admin/master/category/index.tsx
@@ -4,21 +4,11 @@ import { Card, CardContent } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Trash2, Plus, X } from 'lucide-react';
import { DataTable } from '@/components/data-table';
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogMedia,
- AlertDialogTitle,
-} from "@/components/ui/alert-dialog"
import { useCategoryIndex } from './hooks/use-category-index';
import { getColumns } from './partials/columns';
import { CategoryFormModal } from './partials/category-form-modal';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
export default function CategoryIndex({ categories }: { categories: Category[] }) {
const {
@@ -97,58 +87,30 @@ export default function CategoryIndex({ categories }: { categories: Category[] }
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus kategori?
-
- Tindakan ini tidak dapat dibatalkan. Kategori {categoryToDelete?.name} akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Kategori {categoryToDelete?.name} akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} kategori?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}
diff --git a/resources/js/pages/admin/master/product/index.tsx b/resources/js/pages/admin/master/product/index.tsx
index 1af3e46..09f267b 100644
--- a/resources/js/pages/admin/master/product/index.tsx
+++ b/resources/js/pages/admin/master/product/index.tsx
@@ -20,6 +20,7 @@ import productRoutes from '@/routes/product';
import { useProductIndex } from './hooks/use-product-index';
import { getColumns } from './partials/columns';
import { ImagePreviewDialog } from './partials/image-preview-dialog';
+import { DeleteConfirmation } from '@/components/modal/delete-confirmation';
export default function ProductIndex({ products, categories }: { products: Product[], categories: Category[] }) {
const {
@@ -100,58 +101,30 @@ export default function ProductIndex({ products, categories }: { products: Produ
{/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus produk?
-
- Tindakan ini tidak dapat dibatalkan. Produk {productToDelete?.name} akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. Produk {productToDelete?.name} akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmDelete}
+ />
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} produk?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
- {/* Single Delete Confirmation */}
-
-
-
-
-
-
- Hapus pegawai?
-
- Tindakan ini tidak dapat dibatalkan. Pegawai {userToDelete?.name} akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
-
{/* Reset Password Confirmation */}
@@ -131,34 +107,31 @@ export default function UserIndex({ users, defaultPassword }: { users: User[], d
+ {/* Single Delete Confirmation */}
+
+ Tindakan ini tidak dapat dibatalkan. Pegawai {userToDelete?.name} akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmDelete}
+ />
+
{/* Bulk Delete Confirmation */}
-
-
-
-
-
-
- Hapus {rowsToDelete.length} pegawai?
-
- Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} pegawai yang terpilih akan dihapus secara permanen.
-
-
-
-
-
- Batal
-
-
-
- Hapus
-
-
-
-
+
+ Tindakan ini tidak dapat dibatalkan. {rowsToDelete.length} item yang terpilih akan dihapus secara permanen.
+ >
+ }
+ onDelete={confirmBulkDelete}
+ />
);
}