feat(web): add inventory browser API client
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
import { apiRequest } from './api';
|
||||||
|
import type { AssetInformationStatus, AssetOperationalStatus } from './api';
|
||||||
|
|
||||||
|
export interface InventoryBrowserArea {
|
||||||
|
id: string;
|
||||||
|
code: string;
|
||||||
|
name: string;
|
||||||
|
commonName: string | null;
|
||||||
|
type: { id: string; code: string; name: string };
|
||||||
|
informationStatus: AssetInformationStatus;
|
||||||
|
operationalStatus: AssetOperationalStatus;
|
||||||
|
currentOperator: { id: string; code: string; name: string } | null;
|
||||||
|
yacimientoCount: number;
|
||||||
|
inventoryCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InventoryBrowserItem {
|
||||||
|
id: string;
|
||||||
|
code: string;
|
||||||
|
name: string;
|
||||||
|
commonName: string | null;
|
||||||
|
type: { id: string; code: string; name: string };
|
||||||
|
parent: { id: string; code: string; name: string } | null;
|
||||||
|
informationStatus: AssetInformationStatus;
|
||||||
|
operationalStatus: AssetOperationalStatus;
|
||||||
|
isInventoryInstance: boolean;
|
||||||
|
inventoryFamily: { id: string; code: string; name: string; level: string } | null;
|
||||||
|
childrenCount: number;
|
||||||
|
hasGeometry: boolean;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InventoryBrowserParent {
|
||||||
|
id: string;
|
||||||
|
code: string;
|
||||||
|
name: string;
|
||||||
|
typeCode: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listInventoryAreas(params: { search?: string; operatorCompanyId?: string } = {}) {
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
if (params.search?.trim()) query.set('search', params.search.trim());
|
||||||
|
if (params.operatorCompanyId) query.set('operatorCompanyId', params.operatorCompanyId);
|
||||||
|
const suffix = query.size ? `?${query}` : '';
|
||||||
|
return apiRequest<{ data: InventoryBrowserArea[]; meta: { count: number } }>(`/inventory-browser/areas${suffix}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listInventoryChildren(
|
||||||
|
parentId: string,
|
||||||
|
params: { search?: string; operatorCompanyId?: string } = {},
|
||||||
|
) {
|
||||||
|
const query = new URLSearchParams();
|
||||||
|
if (params.search?.trim()) query.set('search', params.search.trim());
|
||||||
|
if (params.operatorCompanyId) query.set('operatorCompanyId', params.operatorCompanyId);
|
||||||
|
const suffix = query.size ? `?${query}` : '';
|
||||||
|
return apiRequest<{
|
||||||
|
parent: InventoryBrowserParent;
|
||||||
|
data: InventoryBrowserItem[];
|
||||||
|
meta: { count: number; hasMore: boolean };
|
||||||
|
}>(`/inventory-browser/${parentId}/children${suffix}`);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user