Files
tfm_ainventory/frontend/lib/db.ts
Daniel Bedeleanu b5fb2a8cdb fix: add photo_path fields to frontend Item interface to display saved photos
The backend returns photo_path, photo_thumbnail_path, and photo_upload_date
from the AI auto-save feature, but the frontend Item interface was missing
these fields, causing images not to display in ItemDetailModal and InventoryTable.

Updated:
- frontend/lib/db.ts: Added missing photo fields to Item interface
- frontend/components/ItemDetailModal.tsx: Use photo_path first, fallback to image_url
- frontend/components/InventoryTable.tsx: Use photo_path first, fallback to image_url

This ensures the UI can now display photos saved by the auto-photo-save feature.
2026-04-21 19:45:19 +03:00

52 lines
1.1 KiB
TypeScript

import Dexie, { Table } from 'dexie';
export interface Item {
id?: number;
barcode: string;
name: string;
category: string;
part_number?: string;
color?: string;
specs?: string;
quantity: number;
min_quantity: number;
image_url?: string;
box_label?: string;
labels_data?: string;
serial_number?: string;
type?: string;
description?: string;
connector?: string;
size?: string;
ocr_text?: string;
photo_path?: string;
photo_thumbnail_path?: string;
photo_upload_date?: string;
}
export interface PendingOperation {
id?: number;
type: 'CHECK_IN' | 'CHECK_OUT' | 'TRASH';
barcode: string;
quantity: number;
timestamp: number;
synced: 0 | 1; // 0 for false, 1 for true
uuid: string;
details?: string;
}
export class InventoryDatabase extends Dexie {
items!: Table<Item>;
pendingOperations!: Table<PendingOperation>;
constructor() {
super('InventoryDatabase');
this.version(5).stores({
items: '++id, barcode, name, category, part_number, color, box_label, ocr_text',
pendingOperations: '++id, barcode, timestamp, synced, uuid'
});
}
}
export const db = new InventoryDatabase();