feat(f6): consumir compatibilidades y campos técnicos de familias
This commit is contained in:
@@ -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<InventoryFamilyFindings>(`/inventory-families/${familyId}/findings`);
|
||||
}
|
||||
|
||||
export function getInventoryFamilyAttributes(familyId: string) {
|
||||
return apiRequest<InventoryFamilyAttributes>(`/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<InventoryFamily>('/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<InventoryFamilyAttribute>(`/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<InventoryFamilyAttribute>(`/inventory-families/${familyId}/attributes/${attributeId}`, {
|
||||
method: 'PATCH', body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function replaceInventoryFamilyFindings(familyId: string, input: {
|
||||
itemIds: string[];
|
||||
reason: string;
|
||||
|
||||
Reference in New Issue
Block a user