feat(f6): consumir compatibilidades y campos técnicos de familias
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
import { apiRequest } from './api';
|
import { apiRequest } from './api';
|
||||||
|
|
||||||
export type InventoryStructureKind = 'EMPRESA' | 'DEPARTAMENTO' | 'AREA' | 'YACIMIENTO' | 'INSTALACION' | 'SUBINSTALACION';
|
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 {
|
export interface InventoryFamily {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -11,12 +18,31 @@ export interface InventoryFamily {
|
|||||||
informationLabels: string[];
|
informationLabels: string[];
|
||||||
sourceReference?: string | null;
|
sourceReference?: string | null;
|
||||||
isActive?: boolean;
|
isActive?: boolean;
|
||||||
parentFamilyId: string | null;
|
parentFamilyIds: string[];
|
||||||
parentFamilyCode: string | null;
|
parentFamilies: InventoryFamilyParent[];
|
||||||
parentFamilyName: string | null;
|
|
||||||
assetCount?: number;
|
assetCount?: number;
|
||||||
findingCount?: number;
|
findingCount?: number;
|
||||||
findingItemIds?: string[];
|
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 {
|
export interface InventoryStructureLevel {
|
||||||
@@ -64,13 +90,7 @@ export interface InventoryFamilyFinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface InventoryFamilyFindings {
|
export interface InventoryFamilyFindings {
|
||||||
family: {
|
family: InventoryFamily;
|
||||||
id: string;
|
|
||||||
code: string;
|
|
||||||
name: string;
|
|
||||||
level: string;
|
|
||||||
informationLabels: string[];
|
|
||||||
};
|
|
||||||
items: InventoryFamilyFinding[];
|
items: InventoryFamilyFinding[];
|
||||||
count: number;
|
count: number;
|
||||||
}
|
}
|
||||||
@@ -112,6 +132,10 @@ export function getInventoryFamilyFindings(familyId: string) {
|
|||||||
return apiRequest<InventoryFamilyFindings>(`/inventory-families/${familyId}/findings`);
|
return apiRequest<InventoryFamilyFindings>(`/inventory-families/${familyId}/findings`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getInventoryFamilyAttributes(familyId: string) {
|
||||||
|
return apiRequest<InventoryFamilyAttributes>(`/inventory-families/${familyId}/attributes`);
|
||||||
|
}
|
||||||
|
|
||||||
export async function listInventoryFamiliesAdmin() {
|
export async function listInventoryFamiliesAdmin() {
|
||||||
return (await apiRequest<{ data: InventoryFamily[] }>('/inventory-families/admin')).data;
|
return (await apiRequest<{ data: InventoryFamily[] }>('/inventory-families/admin')).data;
|
||||||
}
|
}
|
||||||
@@ -119,7 +143,7 @@ export async function listInventoryFamiliesAdmin() {
|
|||||||
export function createInventoryFamily(input: {
|
export function createInventoryFamily(input: {
|
||||||
level: 'INSTALLATION' | 'SUBINSTALLATION';
|
level: 'INSTALLATION' | 'SUBINSTALLATION';
|
||||||
name: string;
|
name: string;
|
||||||
parentFamilyId?: string | null;
|
parentFamilyIds?: string[];
|
||||||
informationLabels?: string[];
|
informationLabels?: string[];
|
||||||
}) {
|
}) {
|
||||||
return apiRequest<InventoryFamily>('/inventory-families', {
|
return apiRequest<InventoryFamily>('/inventory-families', {
|
||||||
@@ -129,7 +153,7 @@ export function createInventoryFamily(input: {
|
|||||||
|
|
||||||
export function updateInventoryFamily(familyId: string, input: {
|
export function updateInventoryFamily(familyId: string, input: {
|
||||||
name?: string;
|
name?: string;
|
||||||
parentFamilyId?: string | null;
|
parentFamilyIds?: string[];
|
||||||
informationLabels?: string[];
|
informationLabels?: string[];
|
||||||
isActive?: boolean;
|
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: {
|
export function replaceInventoryFamilyFindings(familyId: string, input: {
|
||||||
itemIds: string[];
|
itemIds: string[];
|
||||||
reason: string;
|
reason: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user