Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
98e2b9861b
commit
1f244450b2
@@ -381,9 +381,6 @@ export function CollectionDetail({
|
||||
const { user } = useAuth();
|
||||
const [entries, setEntries] = useState<any[]>([]);
|
||||
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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user