diff --git a/resources/js/pages/admin/finance/payroll/partials/payroll-form-modal.tsx b/resources/js/pages/admin/finance/payroll/partials/payroll-form-modal.tsx index 5484dbd..fb86997 100644 --- a/resources/js/pages/admin/finance/payroll/partials/payroll-form-modal.tsx +++ b/resources/js/pages/admin/finance/payroll/partials/payroll-form-modal.tsx @@ -1,9 +1,3 @@ -import { useForm } from '@inertiajs/react'; -import { Loader, Plus, Trash2 } from 'lucide-react'; -import { X, Save } from 'lucide-react'; -import { useEffect } from 'react'; -import { NumericFormat } from 'react-number-format'; -import { toast } from 'sonner'; import { Button } from '@/components/ui/button'; import { Dialog, @@ -11,14 +5,24 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "@/components/ui/dialog" -import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from '@/components/ui/empty'; -import { FieldGroup } from "@/components/ui/field" -import { Input } from "@/components/ui/input" -import { Label } from "@/components/ui/label" +} from '@/components/ui/dialog'; +import { + Empty, + EmptyDescription, + EmptyHeader, + EmptyTitle, +} from '@/components/ui/empty'; +import { FieldGroup } from '@/components/ui/field'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; import payrollRoutes from '@/routes/payroll'; import type { Payroll } from '@/types'; +import { useForm } from '@inertiajs/react'; +import { Loader, Plus, Save, Trash2, X } from 'lucide-react'; +import { useEffect } from 'react'; +import { NumericFormat } from 'react-number-format'; +import { toast } from 'sonner'; interface PayrollFormModalProps { isOpen: boolean; @@ -26,19 +30,29 @@ interface PayrollFormModalProps { payroll: Payroll | null; } -export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalProps) { - const { data, setData, patch, processing, errors, reset, clearErrors } = useForm({ - adjustments: [] as { type: 'bonus' | 'deduction', amount: number, description: string }[], - }); +export function PayrollFormModal({ + isOpen, + onClose, + payroll, +}: PayrollFormModalProps) { + const { data, setData, patch, processing, errors, reset, clearErrors } = + useForm({ + adjustments: [] as { + type: 'bonus' | 'deduction'; + amount: number; + description: string; + }[], + }); useEffect(() => { if (payroll) { setData({ - adjustments: payroll.adjustments?.map(adj => ({ - type: adj.type, - amount: adj.amount, - description: adj.description - })) || [], + adjustments: + payroll.adjustments?.map((adj) => ({ + type: adj.type, + amount: adj.amount, + description: adj.description, + })) || [], }); } else { reset(); @@ -56,7 +70,7 @@ export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalP const addAdjustment = () => { setData('adjustments', [ ...data.adjustments, - { type: 'bonus', amount: 0, description: '' } + { type: 'bonus', amount: 0, description: '' }, ]); }; @@ -89,14 +103,24 @@ export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalP !open && handleClose()}> - Penyesuaian Penggajian - {payroll?.user?.name} + + Penyesuaian Penggajian - {payroll?.user?.name} +
-
-

Bonus & Potongan

- @@ -114,30 +138,61 @@ export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalP )} {data.adjustments.map((adj, index) => ( -
-
+
+
- + updateAdjustment(index, 'type', val)} - className="flex items-center gap-6 w-fit" + onValueChange={(val) => + updateAdjustment( + index, + 'type', + val, + ) + } + className="flex w-fit items-center gap-6" >
- - + +
- - + +
- + { - updateAdjustment(index, 'amount', values.value) + updateAdjustment( + index, + 'amount', + values.value, + ); }} placeholder="Rp 0" - autoComplete='off' + autoComplete="off" />
- + - updateAdjustment(index, 'description', e.target.value) + onChange={(e) => + updateAdjustment( + index, + 'description', + e.target.value, + ) } placeholder="Contoh: Lembur" + autoComplete="off" />
@@ -170,7 +240,7 @@ export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalP type="button" variant="ghost" size="icon" - className="text-red-500 mt-6" + className="mt-6 text-red-500" onClick={() => removeAdjustment(index)} > @@ -181,12 +251,25 @@ export function PayrollFormModal({ isOpen, onClose, payroll }: PayrollFormModalP
- -