From 44466f156641b6c42e239e1897b0f50769ce0fa2 Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Fri, 11 Sep 2026 13:21:20 +0700 Subject: [PATCH] feat: add edit mode for locked 'LUNAS' orders and comment out action columns in ReportByPersonGrid --- src/app/(app)/my-orders/[id]/page.tsx | 38 +++++++++++++++++++++------ src/components/ReportByPersonGrid.tsx | 12 ++++----- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/app/(app)/my-orders/[id]/page.tsx b/src/app/(app)/my-orders/[id]/page.tsx index 518d375..0321971 100644 --- a/src/app/(app)/my-orders/[id]/page.tsx +++ b/src/app/(app)/my-orders/[id]/page.tsx @@ -436,12 +436,14 @@ function SubmissionRow({ const [paidAmount, setPaidAmount] = useState(sub.paid_amount ?? '') const [status, setStatus] = useState(sub.payment_status || 'BELUM_BAYAR') const [saving, setSaving] = useState(false) + const [isEditingLunas, setIsEditingLunas] = useState(false) // Sync state when props change after save useEffect(() => { setBill(sub.bill ?? '') setPaidAmount(sub.paid_amount ?? '') setStatus(sub.payment_status || 'BELUM_BAYAR') + setIsEditingLunas(false) // reset edit mode after save/refresh }, [sub]) const handleSave = async (overrideStatus?: string, overridePaid?: string | number) => { @@ -551,7 +553,7 @@ function SubmissionRow({ type="number" placeholder="Rp" value={bill} - disabled={sub.payment_status === 'LUNAS'} + disabled={sub.payment_status === 'LUNAS' && !isEditingLunas} onChange={e => { const val = e.target.value setBill(val) @@ -574,7 +576,7 @@ function SubmissionRow({ type="number" placeholder="Rp" value={paidAmount} - disabled={sub.payment_status === 'LUNAS'} + disabled={sub.payment_status === 'LUNAS' && !isEditingLunas} onChange={e => { const val = e.target.value setPaidAmount(val) @@ -593,7 +595,7 @@ function SubmissionRow({ Status - + @@ -606,7 +608,22 @@ function SubmissionRow({ - {sub.payment_status !== 'LUNAS' ? ( + {sub.payment_status === 'LUNAS' && !isEditingLunas ? ( + // Locked state — show paid badge + edit icon + + + Telah Lunas + + setIsEditingLunas(true)} + title="Edit tagihan" + className="ml-2 h-8 w-8 shrink-0 flex items-center justify-center rounded-md border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-500 hover:text-[#1B2CC1] hover:border-[#1B2CC1] transition-colors" + > + + + + ) : ( + // Editable state — show save + cancel <> {saving ? : <> Simpan>} + + {sub.payment_status === 'LUNAS' && isEditingLunas && ( + setIsEditingLunas(false)} + className="h-8 px-3 shrink-0 flex items-center justify-center rounded-md border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-500 hover:text-rose-600 hover:border-rose-300 text-xs font-semibold transition-colors" + > + Batal + + )} {currentBalance !== undefined && currentBalance > 0 && status !== 'LUNAS' && ( )} > - ) : ( - - Telah Lunas - )} > diff --git a/src/components/ReportByPersonGrid.tsx b/src/components/ReportByPersonGrid.tsx index 6c47cc0..fe86d90 100644 --- a/src/components/ReportByPersonGrid.tsx +++ b/src/components/ReportByPersonGrid.tsx @@ -144,7 +144,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, Nama Pemesan Total PO Total Piutang - Aksi + {/* Aksi */} @@ -191,7 +191,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, Lunas: {formatRupiah(userObj.totalPaid)} )} - + {/* {unpaid.length > 0 ? ( openModal(e, unpaid.map((s: any) => s.id), `Semua tagihan ${userObj.user.name}`, userObj.totalPiutang, userObj.user.id)} @@ -201,7 +201,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, Lunasi Semua ):( Selesai)} - + */} {isExpanded && ( @@ -219,7 +219,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, Tgl Order Status Tagihan - Aksi + {/* Aksi */} @@ -244,7 +244,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, {sub.bill ? formatRupiah(sub.bill) : 'Rp0'} - + {/* {isUnpaid ? ( openModal(e, [sub.id], `PO: ${sub.orderTitle}`, Number(sub.bill) || 0, sub.user.id)} @@ -257,7 +257,7 @@ export default function ReportByPersonGrid({ data, balancesData = [], creatorId, ) : ( Selesai )} - + */} ) })}
Lunas: {formatRupiah(userObj.totalPaid)}