added new log column "take_date"
Also removed unnesesarry code notes
This commit is contained in:
@@ -13,14 +13,12 @@ interface BorrowItem {
|
|||||||
|
|
||||||
const LOCAL_STORAGE_KEY = "borrowableItems";
|
const LOCAL_STORAGE_KEY = "borrowableItems";
|
||||||
|
|
||||||
// Einfache Type-Guard/Validierung
|
|
||||||
const isBorrowItem = (v: any): v is BorrowItem =>
|
const isBorrowItem = (v: any): v is BorrowItem =>
|
||||||
v &&
|
v &&
|
||||||
typeof v.id === "number" &&
|
typeof v.id === "number" &&
|
||||||
(typeof v.item_name === "string" || typeof v.name === "string") &&
|
(typeof v.item_name === "string" || typeof v.name === "string") &&
|
||||||
(typeof v.can_borrow_role === "string" || typeof v.role === "string");
|
(typeof v.can_borrow_role === "string" || typeof v.role === "string");
|
||||||
|
|
||||||
// Helfer: unterschiedliche Server-Shapes normalisieren
|
|
||||||
function normalizeBorrowable(data: any): BorrowItem[] {
|
function normalizeBorrowable(data: any): BorrowItem[] {
|
||||||
const rawArr = Array.isArray(data)
|
const rawArr = Array.isArray(data)
|
||||||
? data
|
? data
|
||||||
@@ -52,7 +50,6 @@ function normalizeBorrowable(data: any): BorrowItem[] {
|
|||||||
.filter(Boolean) as BorrowItem[];
|
.filter(Boolean) as BorrowItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook, der automatisch aus dem Local Storage liest und auf Änderungen hört
|
|
||||||
function useBorrowableItems() {
|
function useBorrowableItems() {
|
||||||
const [items, setItems] = React.useState<BorrowItem[]>([]);
|
const [items, setItems] = React.useState<BorrowItem[]>([]);
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ type Loan = {
|
|||||||
loan_code: number;
|
loan_code: number;
|
||||||
start_date: string;
|
start_date: string;
|
||||||
end_date: string;
|
end_date: string;
|
||||||
|
take_date: string | null;
|
||||||
returned_date: string | null;
|
returned_date: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
loaned_items_id: number[];
|
loaned_items_id: number[];
|
||||||
@@ -89,6 +90,9 @@ const Form4: React.FC = () => {
|
|||||||
<th className="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600">
|
<th className="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600">
|
||||||
Ende
|
Ende
|
||||||
</th>
|
</th>
|
||||||
|
<th className="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600">
|
||||||
|
Abgeholt
|
||||||
|
</th>
|
||||||
<th className="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600">
|
<th className="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600">
|
||||||
Zurückgegeben
|
Zurückgegeben
|
||||||
</th>
|
</th>
|
||||||
@@ -118,6 +122,9 @@ const Form4: React.FC = () => {
|
|||||||
<td className="px-4 py-3 whitespace-nowrap font-mono tabular-nums text-gray-900">
|
<td className="px-4 py-3 whitespace-nowrap font-mono tabular-nums text-gray-900">
|
||||||
{formatDate(loan.end_date)}
|
{formatDate(loan.end_date)}
|
||||||
</td>
|
</td>
|
||||||
|
<td className="px-4 py-3 whitespace-nowrap font-mono tabular-nums text-gray-900">
|
||||||
|
{formatDate(loan.take_date)}
|
||||||
|
</td>
|
||||||
<td className="px-4 py-3 whitespace-nowrap font-mono tabular-nums text-gray-900">
|
<td className="px-4 py-3 whitespace-nowrap font-mono tabular-nums text-gray-900">
|
||||||
{formatDate(loan.returned_date)}
|
{formatDate(loan.returned_date)}
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user