F3.1: corregir contrato de contexto móvil estructural
This commit is contained in:
@@ -28,6 +28,16 @@ type ParentRow = {
|
||||
inventoryFamilyId: string | null;
|
||||
};
|
||||
|
||||
type FieldTypesBase = {
|
||||
context: {
|
||||
area: { id: string; code: string; name: string };
|
||||
operatorCompany: { id: string; code: string; name: string };
|
||||
inspection: { id: string; code: string; status: string };
|
||||
};
|
||||
parent: { id: string; code: string; name: string };
|
||||
data: Array<Record<string, unknown> & { id: string; code: string; name: string }>;
|
||||
};
|
||||
|
||||
const STRUCTURAL_CHILD: Record<string, string | undefined> = {
|
||||
area: 'yacimiento',
|
||||
yacimiento: 'instalacion',
|
||||
@@ -48,12 +58,8 @@ export class F3FieldInventoryStructureService {
|
||||
parentId: string | undefined,
|
||||
principal: AuthPrincipal,
|
||||
) {
|
||||
const base = await this.fieldInventory.types(visitId, parentId, principal) as {
|
||||
context: { areaId: string };
|
||||
parent: { id: string; code: string; name: string };
|
||||
data: Array<Record<string, unknown> & { id: string; code: string; name: string }>;
|
||||
};
|
||||
const effectiveParentId = parentId ?? base.context.areaId;
|
||||
const base = await this.fieldInventory.types(visitId, parentId, principal) as unknown as FieldTypesBase;
|
||||
const effectiveParentId = parentId ?? base.context.area.id;
|
||||
const parent = await this.parent(effectiveParentId);
|
||||
const expectedTypeCode = STRUCTURAL_CHILD[parent.typeCode.toLowerCase()];
|
||||
const data = expectedTypeCode
|
||||
|
||||
Reference in New Issue
Block a user