From 7ac19ab20db387d42448c2dfa72ebb88b9fce57f Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 26 Apr 2026 08:51:42 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- .../collections/payment-plans-panel.tsx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/collections/payment-plans-panel.tsx b/src/components/collections/payment-plans-panel.tsx index cef9093..fd9f86b 100644 --- a/src/components/collections/payment-plans-panel.tsx +++ b/src/components/collections/payment-plans-panel.tsx @@ -65,7 +65,13 @@ function addInterval(dateStr: string, frequency: Frequency, n: number) { return d.toISOString().slice(0, 10); } -export function PaymentPlansPanel({ collectionId }: { collectionId: string }) { +export function PaymentPlansPanel({ + collectionId, + caseId, +}: { + collectionId: string; + caseId?: string | null; +}) { const { user } = useAuth(); const [plans, setPlans] = useState([]); const [installments, setInstallments] = useState>({}); @@ -119,6 +125,25 @@ export function PaymentPlansPanel({ collectionId }: { collectionId: string }) { else load(); }; + const updatePaidAmount = async (id: string, value: string) => { + const num = value === "" ? null : parseFloat(value) || 0; + setInstallments((prev) => { + const next: Record = {}; + Object.entries(prev).forEach(([k, list]) => { + next[k] = list.map((x) => (x.id === id ? { ...x, paid_amount: num } : x)); + }); + return next; + }); + const { error } = await supabase + .from("payment_plan_installments") + .update({ paid_amount: num }) + .eq("id", id); + if (error) { + toast.error("Could not save", { description: error.message }); + load(); + } + }; + const updatePlanStatus = async (planId: string, status: PlanStatus) => { const { error } = await supabase .from("payment_plans")