From 96738bfdcb1de62a6a1cf58475dcc5b57588e0bb Mon Sep 17 00:00:00 2001 From: enlineawork Date: Wed, 9 Sep 2026 09:24:06 -0300 Subject: [PATCH] =?UTF-8?q?feat(f6):=20consumir=20compatibilidades=20y=20c?= =?UTF-8?q?ampos=20t=C3=A9cnicos=20de=20familias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-v2/src/lib/inventoryStructureApi.ts | 76 +++++++++++++++++++++---- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/web-v2/src/lib/inventoryStructureApi.ts b/web-v2/src/lib/inventoryStructureApi.ts index e8e8468..a289e9b 100644 --- a/web-v2/src/lib/inventoryStructureApi.ts +++ b/web-v2/src/lib/inventoryStructureApi.ts @@ -1,6 +1,13 @@ import { apiRequest } from './api'; export type InventoryStructureKind = 'EMPRESA' | 'DEPARTAMENTO' | 'AREA' | 'YACIMIENTO' | 'INSTALACION' | 'SUBINSTALACION'; +export type InventoryFamilyAttributeDataType = 'TEXT' | 'NUMBER' | 'BOOLEAN' | 'DATE' | 'DATETIME' | 'SELECT'; + +export interface InventoryFamilyParent { + id: string; + code: string; + name: string; +} export interface InventoryFamily { id: string; @@ -11,12 +18,31 @@ export interface InventoryFamily { informationLabels: string[]; sourceReference?: string | null; isActive?: boolean; - parentFamilyId: string | null; - parentFamilyCode: string | null; - parentFamilyName: string | null; + parentFamilyIds: string[]; + parentFamilies: InventoryFamilyParent[]; assetCount?: number; findingCount?: number; findingItemIds?: string[]; + technicalAttributeCount?: number; +} + +export interface InventoryFamilyAttribute { + id: string; + inventoryFamilyId: string; + code: string; + name: string; + dataType: InventoryFamilyAttributeDataType; + isRequired: boolean; + isActive: boolean; + unit: string | null; + options: string[] | null; + sortOrder: number; +} + +export interface InventoryFamilyAttributes { + family: InventoryFamily; + items: InventoryFamilyAttribute[]; + count: number; } export interface InventoryStructureLevel { @@ -64,13 +90,7 @@ export interface InventoryFamilyFinding { } export interface InventoryFamilyFindings { - family: { - id: string; - code: string; - name: string; - level: string; - informationLabels: string[]; - }; + family: InventoryFamily; items: InventoryFamilyFinding[]; count: number; } @@ -112,6 +132,10 @@ export function getInventoryFamilyFindings(familyId: string) { return apiRequest(`/inventory-families/${familyId}/findings`); } +export function getInventoryFamilyAttributes(familyId: string) { + return apiRequest(`/inventory-families/${familyId}/attributes`); +} + export async function listInventoryFamiliesAdmin() { return (await apiRequest<{ data: InventoryFamily[] }>('/inventory-families/admin')).data; } @@ -119,7 +143,7 @@ export async function listInventoryFamiliesAdmin() { export function createInventoryFamily(input: { level: 'INSTALLATION' | 'SUBINSTALLATION'; name: string; - parentFamilyId?: string | null; + parentFamilyIds?: string[]; informationLabels?: string[]; }) { return apiRequest('/inventory-families', { @@ -129,7 +153,7 @@ export function createInventoryFamily(input: { export function updateInventoryFamily(familyId: string, input: { name?: string; - parentFamilyId?: string | null; + parentFamilyIds?: string[]; informationLabels?: string[]; isActive?: boolean; }) { @@ -138,6 +162,34 @@ export function updateInventoryFamily(familyId: string, input: { }); } +export function createInventoryFamilyAttribute(familyId: string, input: { + code: string; + name: string; + dataType: InventoryFamilyAttributeDataType; + isRequired?: boolean; + unit?: string | null; + options?: string[]; + sortOrder?: number; +}) { + return apiRequest(`/inventory-families/${familyId}/attributes`, { + method: 'POST', body: JSON.stringify(input), + }); +} + +export function updateInventoryFamilyAttribute(familyId: string, attributeId: string, input: { + name?: string; + dataType?: InventoryFamilyAttributeDataType; + isRequired?: boolean; + isActive?: boolean; + unit?: string | null; + options?: string[] | null; + sortOrder?: number; +}) { + return apiRequest(`/inventory-families/${familyId}/attributes/${attributeId}`, { + method: 'PATCH', body: JSON.stringify(input), + }); +} + export function replaceInventoryFamilyFindings(familyId: string, input: { itemIds: string[]; reason: string;