Add clickable relation navigation to inventory panel
CI / basic-check (push) Has been cancelled

This commit is contained in:
Perplexity Bot
2026-08-04 19:58:31 +00:00
parent 92b0136015
commit d2fd4d1078
5 changed files with 97 additions and 48 deletions
+16 -22
View File
@@ -20,6 +20,19 @@ export function InventoryPage() {
const [loadingContext, setLoadingContext] = useState(false);
const [error, setError] = useState<string | null>(null);
const loadContext = async (id: string) => {
setSelectedId(id);
setLoadingContext(true);
try {
const item = await fetchNodeContext(id);
setContext(item);
} catch (err) {
setError(err instanceof Error ? err.message : 'Errore sconosciuto');
} finally {
setLoadingContext(false);
}
};
useEffect(() => {
let active = true;
setLoadingTree(true);
@@ -28,7 +41,7 @@ export function InventoryPage() {
if (!active) return;
setNodes(items);
const first = findFirstNode(items);
setSelectedId(first);
if (first) loadContext(first);
})
.catch((err: Error) => {
if (!active) return;
@@ -42,25 +55,6 @@ export function InventoryPage() {
};
}, []);
useEffect(() => {
if (!selectedId) return;
let active = true;
setLoadingContext(true);
fetchNodeContext(selectedId)
.then((item) => {
if (active) setContext(item);
})
.catch((err: Error) => {
if (active) setError(err.message);
})
.finally(() => {
if (active) setLoadingContext(false);
});
return () => {
active = false;
};
}, [selectedId]);
if (loadingTree) {
return <div className="inventory-empty">Caricamento inventory...</div>;
}
@@ -71,8 +65,8 @@ export function InventoryPage() {
return (
<div className="inventory-layout">
<InventoryTree nodes={nodes} selectedId={selectedId} onSelect={setSelectedId} />
<NodeContextPanel context={context} loading={loadingContext} />
<InventoryTree nodes={nodes} selectedId={selectedId} onSelect={loadContext} />
<NodeContextPanel context={context} loading={loadingContext} onNavigateNode={loadContext} />
</div>
);
}