import { Form, Head, router } from '@inertiajs/react'; import { Plus } from 'lucide-react'; import { useState } from 'react'; import InputError from '@/components/input-error'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { destroy, index as supplierIndex, store, update } from '@/routes/admin/master/suppliers'; import { createSupplierColumns } from './columns'; import type { Supplier } from './columns'; import { ConfirmDialog } from '@/components/confirm-dialog'; import { DataTable } from '@/components/data-table'; type Props = { suppliers: Supplier[]; }; export default function SupplierIndex({ suppliers }: Props) { const [createOpen, setCreateOpen] = useState(false); const [editing, setEditing] = useState(null); const [deleting, setDeleting] = useState(null); function handleDelete() { if (!deleting) { return; } router.delete(destroy(deleting.id), { onSuccess: () => setDeleting(null), }); } const columns = createSupplierColumns({ handleEdit: (supplier) => setEditing(supplier), handleDeleteClick: (supplier) => setDeleting(supplier), }); return ( <>

Supplier

setCreateOpen(false)}> {({ errors, processing }) => { return ( <> Tambah Supplier
); }}
{ if (!open) { setEditing(null); } }} > {editing && (
setEditing(null)}> {({ errors, processing }) => { return ( <> Edit Supplier
); }}
)}
{ if (!open) { setDeleting(null); } }} title="Hapus Supplier" description={`Apakah Anda yakin ingin menghapus supplier "${deleting?.name}"? Tindakan ini tidak dapat dibatalkan.`} confirmLabel="Hapus" onConfirm={handleDelete} />
); } SupplierIndex.layout = { breadcrumbs: [ { title: 'Master', href: supplierIndex(), }, { title: 'Supplier', href: supplierIndex(), }, ], };