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 customerIndex, store, update } from '@/routes/admin/master/customers'; import { createCustomerColumns } from './columns'; import type { Customer } from './columns'; import { ConfirmDialog } from '@/components/confirm-dialog'; import { DataTable } from '@/components/data-table'; type Props = { customers: Customer[]; }; export default function CustomerIndex({ customers }: 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 = createCustomerColumns({ handleEdit: (customer) => setEditing(customer), handleDeleteClick: (customer) => setDeleting(customer), }); return ( <>

Customer

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