From 2def0459065fa7b06421df0676ae0a637b5791ec Mon Sep 17 00:00:00 2001 From: "[dyad]" Date: Fri, 12 Sep 2025 16:24:15 +0200 Subject: [PATCH] [dyad] Fixed BookOut data mapping for item name, SKU, and date formatting - wrote 1 file(s) --- src/pages/BookOut.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/BookOut.tsx b/src/pages/BookOut.tsx index dc56dda..8a79e8d 100644 --- a/src/pages/BookOut.tsx +++ b/src/pages/BookOut.tsx @@ -13,7 +13,7 @@ import { import { columns, BookOutRecord } from "../components/book-out/columns"; import { BookOutDataTable } from "../components/book-out/BookOutDataTable"; import pb from "@/lib/pocketbase"; -import { showError } from "@/utils/toast"; // Import showError +import { showError } from "@/utils/toast"; const BookOut = () => { const [bookOutOpen, setBookOutOpen] = useState(false); @@ -29,12 +29,17 @@ const BookOut = () => { const formattedData: BookOutRecord[] = records.items.map((record: any) => ({ id: record.id, - // Correctly access expanded customer name and item details - customerName: record.expand?.customer?.comapny_name || 'N/A', // Use 'comapny_name' as per schema - itemName: record.expand?.items?.name || 'N/A', - sku: record.expand?.items?.sku || 'N/A', - quantity: record.quantity || 0, // Default to 0 if quantity is missing - dateBookedOut: record.bookOutDate ? new Date(record.bookOutDate).toISOString() : 'Invalid Date', // Ensure date is correctly parsed and formatted + customerName: record.expand?.customer?.comapny_name || 'N/A', // Customer name from expanded relation + itemName: record.expand?.items?.name || 'N/A', // Item name (description) from expanded stock item + sku: record.expand?.items?.sku || 'N/A', // SKU from expanded stock item + quantity: record.quantity || 0, // Quantity from record field + dateBookedOut: record.date_booked_out + ? new Date(record.date_booked_out).toLocaleDateString("en-ZA", { + year: "numeric", + month: "short", + day: "numeric", + }) + : 'N/A', // Properly formatted date or N/A })); setBookOutRecords(formattedData); } catch (error) {