Files
NetMapper2026/frontend/src/pages/InventoryView.tsx
T
Perplexity Bot 871f4d0547
CI / basic-check (push) Has been cancelled
Add basic frontend: sidebar, views and inventory table
2026-08-03 22:06:00 +00:00

49 lines
1.3 KiB
TypeScript

import { useState, useEffect } from 'react';
import { AppLayout } from '../components/AppLayout';
import { fetchObjects } from '../lib/api';
export function InventoryView() {
const [objects, setObjects] = useState<Awaited<ReturnType<typeof fetchObjects>>>([]);
useEffect(() => {
fetchObjects().then(setObjects);
}, []);
return (
<AppLayout current="inventory" onNavigate={() => {}}>
<header className="header">
<h1 className="page-title">Inventory</h1>
</header>
<div className="card">
<table className="table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Vendor</th>
<th>Model</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{objects.length === 0 && (
<tr>
<td colSpan={5} className="empty">Nessun oggetto</td>
</tr>
)}
{objects.map(o => (
<tr key={o.id}>
<td>{o.name}</td>
<td>{o.type}</td>
<td>{o.vendor ?? '-'}</td>
<td>{o.model ?? '-'}</td>
<td>{o.status ?? '-'}</td>
</tr>
))}
</tbody>
</table>
</div>
</AppLayout>
);
}