diff --git a/src/components/cases/collections-tab.tsx b/src/components/cases/collections-tab.tsx index c66d7db..8b72808 100644 --- a/src/components/cases/collections-tab.tsx +++ b/src/components/cases/collections-tab.tsx @@ -381,9 +381,6 @@ export function CollectionDetail({ const { user } = useAuth(); const [entries, setEntries] = useState([]); const [loading, setLoading] = useState(true); - const [chargeOpen, setChargeOpen] = useState(false); - const [paymentOpen, setPaymentOpen] = useState(false); - const [bankOpen, setBankOpen] = useState(false); const [importOpen, setImportOpen] = useState(false); // Editable header fields @@ -426,8 +423,8 @@ export function CollectionDetail({ } }; - // Insert a blank row at the end (sort_order = max+10) - const addBlankRow = async () => { + // Insert a new row at the end. Optional preset for transaction_type / description. + const addBlankRow = async (preset?: { transaction_type?: string; description?: string }) => { const maxSort = entries.reduce((m: number, e: any) => Math.max(m, Number(e.sort_order) || 0), 0); const today = new Date().toISOString().slice(0, 10); const { data, error } = await supabase @@ -435,7 +432,8 @@ export function CollectionDetail({ .insert({ collection_id: collection.id, entry_date: today, - transaction_type: "adjustment", + transaction_type: preset?.transaction_type ?? "adjustment", + description: preset?.description ?? null, sort_order: maxSort + 10, created_by: user?.id, })