fixedproblems

This commit is contained in:
davidels1 2025-09-25 10:40:43 +02:00
parent 39a48e3b4b
commit 6c4ec2c423
3 changed files with 26 additions and 15 deletions

View file

@ -42,9 +42,9 @@ export function AddItemForm({ setOpen, refreshData }: AddItemFormProps) {
const records = await pb.collection('stock_items').getList(1, 50, {
fields: 'category',
});
// Explicitly type item.category as string and cat as string
const uniqueCategories = Array.from(new Set(records.items.map((item: { category: string }) => item.category)));
const options = uniqueCategories.map((cat: string) => ({ // Explicitly type 'cat' as string
// Get unique categories from stock_items
const uniqueCategories = Array.from(new Set(records.items.map(item => item.category)));
const options = uniqueCategories.map((cat: string) => ({
value: cat.toLowerCase(),
label: cat,
}));

View file

@ -197,7 +197,24 @@ class Logger {
}
);
return result;
// Map RecordModel[] to LogRecord[]
const items: LogRecord[] = result.items.map((item: any) => ({
id: item.id,
created: item.created,
updated: item.updated,
action: item.action,
level: item.level,
details: item.details,
user: item.user,
module: item.module,
metadata: item.metadata ? JSON.parse(item.metadata) : undefined,
}));
return {
items,
totalItems: result.totalItems,
totalPages: result.totalPages,
};
} catch (error) {
console.error('Failed to retrieve logs:', error);
throw error;

View file

@ -1,12 +1,5 @@
import { useState, useEffect, useCallback } from "react";
import { BookOutForm } </DialogContent>
</Dialog>
</div>
<div className="w-full overflow-hidden">
<BookOutDataTable columns={columns} data={bookOutRecords} />
</div>
</div>
);"../components/book-out/BookOutForm";
import { BookOutForm } from "../components/book-out/BookOutForm";
import { Button } from "@/components/ui/button";
import { PlusCircle } from "lucide-react";
import {
@ -46,14 +39,15 @@ const BookOut = () => {
month: "short",
day: "numeric",
})
: 'N/A', // Properly formatted date or N/A
: 'N/A', // Format the date
}));
setBookOutRecords(formattedData);
} catch (error) {
console.error("Error fetching book out records:", error);
showError("Failed to fetch book out records."); // Show error toast
showError("Failed to load book out records.");
}
}, [refreshTrigger]); // Re-fetch data when refreshTrigger changes
}, []);
useEffect(() => {
fetchBookOutRecords();