Add React inventory UI with tree and node context panel
CI / basic-check (push) Has been cancelled

This commit is contained in:
Perplexity Bot
2026-08-04 19:25:39 +00:00
parent 4466e59684
commit 8b2ed677a7
7 changed files with 479 additions and 31 deletions
+20
View File
@@ -0,0 +1,20 @@
import type { EntityResponse, InventoryTreeNode, ListResponse, NodeContext } from '../types/inventory';
async function handleResponse<T>(response: Response): Promise<T> {
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json() as Promise<T>;
}
export async function fetchInventoryTree(): Promise<InventoryTreeNode[]> {
const response = await fetch('/api/inventory/tree');
const data = await handleResponse<ListResponse<InventoryTreeNode>>(response);
return data.items;
}
export async function fetchNodeContext(id: string): Promise<NodeContext> {
const response = await fetch(`/api/inventory/nodes/${id}/context`);
const data = await handleResponse<EntityResponse<NodeContext>>(response);
return data.item;
}