From 92fbe359069c4ee26efadc472c503583627cc08b Mon Sep 17 00:00:00 2001 From: "[dyad]" Date: Fri, 12 Sep 2025 16:19:37 +0200 Subject: [PATCH] [dyad] Corrected customer name mapping in BookOutForm - wrote 1 file(s) --- src/components/book-out/BookOutForm.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/book-out/BookOutForm.tsx b/src/components/book-out/BookOutForm.tsx index 1f348b6..febdd98 100644 --- a/src/components/book-out/BookOutForm.tsx +++ b/src/components/book-out/BookOutForm.tsx @@ -168,10 +168,17 @@ export function BookOutForm({ setOpen, refreshData }: BookOutFormProps) { async function onSubmit(values: z.infer) { try { + // Find the selected customer by ID to get their name if needed, but we only need the ID for the relation + const selectedCustomer = customers.find(c => c.id === values.customer); + if (!selectedCustomer) { + showError("Invalid customer selected."); + return; + } + // Prepare data for PocketBase const bookOutData = { bookOutDate: values.bookOutDate.toISOString(), - customer: values.customer, // Use the selected customer ID + customer: values.customer, // This should be the customer ID items: values.items.map(item => ({ stockItemId: item.stockItemId, itemName: item.itemName,