Skip to content

Commit e50ca33

Browse files
henrikhenrikperssonHenrik Persson
andauthored
MIM-534: Fetch and show malarEnergiFacilityId (#66)
* Update prisma schemas * Get malarenergi facility id in residence query * Update generated types * Show malarenergi facility id --------- Co-authored-by: Henrik Persson <henrik.persson@iteam.com>
1 parent b6e5203 commit e50ca33

File tree

9 files changed

+140
-3
lines changed

9 files changed

+140
-3
lines changed

packages/property-base/prisma/schema/Residence_balgh.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ model Residence {
3838
3939
residenceType ResidenceType @relation(fields: [residenceTypeId], references: [id], onUpdate: NoAction, map: "fkbalghkeybalgt ")
4040
propertyObject PropertyObject @relation(fields: [propertyObjectId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "fkbalghkeycmobj")
41+
comments TypeText[] @relation("ResidenceToTypeText")
4142
// TODO: Verify relation for checklistId as the InspectionProtocol model was provided but fields need to be verified
4243
// inspectionProtocol InspectionProtocol? @relation(fields: [checklistId], references: [inspectionProtocolId], onUpdate: NoAction, map: "fkbalghkeylbpro ")
4344
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
model Template {
2+
id String @id @map("keycmtep") @db.Char(15)
3+
type String @map("keycmtyp") @db.VarChar(10)
4+
caption String @map("caption") @db.VarChar(100)
5+
6+
typeText TypeText[] @relation("TypeTextToTemplate")
7+
8+
@@map("cmtep")
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
model TypeText {
2+
id String @id @map("keycmtex") @db.Char(15)
3+
keycmtep String @map("keycmtep") @db.Char(15)
4+
keycode String @map("keycode") @db.Char(15)
5+
text String @map("text") @db.VarChar(255)
6+
7+
template Template @relation("TypeTextToTemplate", fields: [keycmtep], references: [id])
8+
residence Residence @relation("ResidenceToTypeText", fields: [keycode], references: [id])
9+
10+
@@map("cmtex")
11+
}

packages/property-base/src/adapters/residence-adapter.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ export type ResidenceWithRelations = Prisma.ResidenceGetPayload<{
3636
}
3737
}
3838
}
39+
comments: {
40+
where: {
41+
template: {
42+
type: 'balgh'
43+
caption: 'Anläggningsid'
44+
}
45+
}
46+
select: {
47+
text: true
48+
}
49+
}
3950
}
4051
}>
4152

@@ -72,6 +83,17 @@ export const getResidenceById = async (
7283
},
7384
},
7485
},
86+
comments: {
87+
where: {
88+
template: {
89+
type: 'balgh',
90+
caption: 'Anläggningsid',
91+
},
92+
},
93+
select: {
94+
text: true,
95+
},
96+
},
7597
},
7698
})
7799
.then(trimStrings)

packages/property-base/src/routes/residences-route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export const routes = (router: KoaRouter) => {
330330
code: residence.propertyObject.propertyStructures[0].buildingCode,
331331
name: residence.propertyObject.propertyStructures[0].buildingName,
332332
},
333+
malarEnergiFacilityId: residence.comments?.[0].text || null,
333334
} satisfies ResidenceDetails
334335

335336
ctx.status = 200

packages/property-base/src/types/residence.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const ResidenceDetailedSchema = z.object({
124124
name: z.string().nullable(),
125125
code: z.string().nullable(),
126126
}),
127+
malarEnergiFacilityId: z.string().nullable(),
127128
})
128129

129130
export type ExternalResidence = z.infer<typeof ResidenceSchema>

packages/property-tree/src/components/residence/ResidenceBasicInfo.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export const ResidenceBasicInfo = ({ residence }: ResidenceBasicInfoProps) => {
7676
Anläggnings ID Mälarenergi
7777
</p>
7878
<p className="font-medium">
79-
{/* {residence.malarenergiFacilityId || '-'} */}
80-
N/A
79+
{residence.malarEnergiFacilityId || 'N/A'}
8180
</p>
8281
</div>
8382
<div>

packages/property-tree/src/services/api/core/generated/api-types.ts

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,84 @@ export interface paths {
15161516
};
15171517
};
15181518
};
1519+
"/workOrders/xpand/rentalPropertyId/{rentalPropertyId}": {
1520+
/**
1521+
* Get work orders by rental property id from xpand
1522+
* @description Retrieves work orders based on the provided rental property id.
1523+
*/
1524+
get: {
1525+
parameters: {
1526+
path: {
1527+
/** @description The rental property id used to fetch work orders. */
1528+
rentalPropertyId: string;
1529+
};
1530+
};
1531+
responses: {
1532+
/** @description Successfully retrieved work orders. */
1533+
200: {
1534+
content: {
1535+
"application/json": {
1536+
content?: {
1537+
totalCount?: number;
1538+
workOrders?: components["schemas"]["XpandWorkOrder"][];
1539+
};
1540+
};
1541+
};
1542+
};
1543+
/** @description Internal server error. Failed to retrieve work orders. */
1544+
500: {
1545+
content: {
1546+
"application/json": {
1547+
/** @example Internal server error */
1548+
error?: string;
1549+
};
1550+
};
1551+
};
1552+
};
1553+
};
1554+
};
1555+
"/workOrders/xpand/{code}": {
1556+
/**
1557+
* Get work order details by rental property id from xpand
1558+
* @description Retrieves work order details.
1559+
*/
1560+
get: {
1561+
parameters: {
1562+
path: {
1563+
/** @description The work order code to fetch details for. */
1564+
code: string;
1565+
};
1566+
};
1567+
responses: {
1568+
/** @description Successfully retrieved work order. */
1569+
200: {
1570+
content: {
1571+
"application/json": {
1572+
content?: components["schemas"]["XpandWorkOrder"];
1573+
};
1574+
};
1575+
};
1576+
/** @description Work order not found. */
1577+
404: {
1578+
content: {
1579+
"application/json": {
1580+
/** @example Work order not found */
1581+
error?: string;
1582+
};
1583+
};
1584+
};
1585+
/** @description Internal server error. Failed to retrieve work order. */
1586+
500: {
1587+
content: {
1588+
"application/json": {
1589+
/** @example Internal server error */
1590+
error?: string;
1591+
};
1592+
};
1593+
};
1594+
};
1595+
};
1596+
};
15191597
"/workOrders": {
15201598
/**
15211599
* Create a new work order
@@ -2190,7 +2268,6 @@ export interface components {
21902268
Registered: string;
21912269
RentalObjectCode: string;
21922270
Status: string;
2193-
UseMasterKey: boolean;
21942271
WorkOrderRows: ({
21952272
Description: string | null;
21962273
LocationCode: string | null;
@@ -2206,6 +2283,20 @@ export interface components {
22062283
}[];
22072284
Url?: string;
22082285
};
2286+
XpandWorkOrder: {
2287+
AccessCaption: string;
2288+
Caption: string | null;
2289+
Code: string;
2290+
ContactCode: string;
2291+
Id: string;
2292+
/** Format: date-time */
2293+
LastChanged: string;
2294+
Priority: string | null;
2295+
/** Format: date-time */
2296+
Registered: string;
2297+
RentalObjectCode: string;
2298+
Status: string;
2299+
};
22092300
Company: {
22102301
id: string;
22112302
propertyObjectId: string;
@@ -2344,6 +2435,7 @@ export interface components {
23442435
name: string | null;
23452436
code: string | null;
23462437
};
2438+
malarEnergiFacilityId: string | null;
23472439
};
23482440
Staircase: {
23492441
id: string;

packages/property-tree/src/services/api/generated/api-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ export interface components {
636636
name: string | null;
637637
code: string | null;
638638
};
639+
malarEnergiFacilityId: string | null;
639640
};
640641
ResidenceSearchResult: {
641642
id: string;

0 commit comments

Comments
 (0)