[dyad] Corrected customer name mapping in BookOutForm - wrote 1 file(s)
This commit is contained in:
parent
b86d694e29
commit
92fbe35906
1 changed files with 8 additions and 1 deletions
|
|
@ -168,10 +168,17 @@ export function BookOutForm({ setOpen, refreshData }: BookOutFormProps) {
|
|||
|
||||
async function onSubmit(values: z.infer<typeof bookOutFormSchema>) {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue