@salesforce/webapp-template-app-react-sample-b2x-experimental 1.84.0 → 1.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/SKILL.md +5 -3
- package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/header-footer.md +8 -0
- package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/page.md +8 -7
- package/dist/.a4drules/skills/webapp-ui-ux/SKILL.md +11 -8
- package/dist/.a4drules/webapp-react.md +54 -0
- package/dist/CHANGELOG.md +16 -0
- package/dist/README.md +24 -0
- package/dist/force-app/main/default/data/Property_Image__c.json +1 -1
- package/dist/force-app/main/default/data/Property_Listing__c.json +1 -1
- package/dist/force-app/main/default/data/prepare-import-unique-fields.js +85 -0
- package/dist/force-app/main/default/permissionsets/Property_Management_Access.permissionset-meta.xml +0 -7
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/index.html +6 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/package.json +3 -3
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/applicationApi.ts +9 -9
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/graphql-operations-types.ts +296 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/graphqlClient.ts +12 -7
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/maintenanceRequestApi.ts +50 -38
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/propertyDetailGraphQL.ts +50 -102
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/propertyListingGraphQL.ts +211 -43
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/userApi.ts +43 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/appLayout.tsx +9 -208
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/appliances.svg +13 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/electrical.svg +39 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/hvac.svg +78 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/pest.svg +5 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/plumbing.svg +7 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/assets/icons/zen-logo.svg +5 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/MaintenanceRequestIcon.tsx +46 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/NavMenu.tsx +53 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/PropertyListingCard.tsx +55 -58
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/PropertyMap.tsx +93 -11
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/PropertySearchFilters.tsx +315 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/StatusBadge.tsx +36 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/components/TopBar.tsx +107 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyAddresses.ts +2 -2
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingAmenities.ts +55 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingPriceRange.ts +64 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyListingSearch.ts +14 -5
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyMapMarkers.ts +54 -11
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/hooks/usePropertyPrimaryImages.ts +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Application.tsx +42 -39
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Contact.tsx +10 -10
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Dashboard.tsx +64 -91
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/HelpCenter.tsx +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Home.tsx +19 -9
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/Maintenance.tsx +79 -100
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/NotFound.tsx +1 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertyDetails.tsx +62 -47
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertyListings.tsx +3 -3
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/pages/PropertySearch.tsx +230 -34
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/routes.tsx +10 -1
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/styles/global.css +64 -0
- package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/utils/geocode.ts +30 -5
- package/dist/package.json +1 -1
- package/dist/setup-cli.mjs +271 -0
- package/package.json +1 -1
- /package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/component.md +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated operation types for B2X GraphQL queries.
|
|
3
|
+
* Regenerate with codegen (e.g. npm run graphql:codegen) when schema or operations change.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ---- MaintenanceRequests ----
|
|
7
|
+
export interface MaintenanceRequestsQueryVariables {
|
|
8
|
+
first: number;
|
|
9
|
+
after?: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MaintenanceRequestsQuery {
|
|
13
|
+
uiapi?: {
|
|
14
|
+
query?: {
|
|
15
|
+
Maintenance_Request__c?: {
|
|
16
|
+
edges?: Array<{
|
|
17
|
+
node?: {
|
|
18
|
+
Id: string;
|
|
19
|
+
ApiName?: string | null;
|
|
20
|
+
Name?: { value?: unknown; displayValue?: string | null } | null;
|
|
21
|
+
Description__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
22
|
+
Type__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
23
|
+
Priority__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
24
|
+
Status__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
25
|
+
Scheduled__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
26
|
+
User__r?: {
|
|
27
|
+
Name?: { value?: unknown; displayValue?: string | null } | null;
|
|
28
|
+
} | null;
|
|
29
|
+
} | null;
|
|
30
|
+
}> | null;
|
|
31
|
+
pageInfo?: {
|
|
32
|
+
hasNextPage?: boolean | null;
|
|
33
|
+
endCursor?: string | null;
|
|
34
|
+
} | null;
|
|
35
|
+
} | null;
|
|
36
|
+
} | null;
|
|
37
|
+
} | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ---- PropertyListings ----
|
|
41
|
+
/** Single-field condition; Property__r filters on related Property (name, address, bedrooms). */
|
|
42
|
+
export type PropertyListingsWhereCondition = {
|
|
43
|
+
Name?: { like: string };
|
|
44
|
+
Listing_Status__c?: { like: string };
|
|
45
|
+
Listing_Price__c?: { gte?: number; lte?: number };
|
|
46
|
+
Property__r?: {
|
|
47
|
+
Name?: { like: string };
|
|
48
|
+
Address__c?: { like: string };
|
|
49
|
+
Bedrooms__c?: { gte?: number };
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** GraphQL ResultOrder values for orderBy (use ResultOrder.Asc / ResultOrder.Desc). */
|
|
53
|
+
export const ResultOrder = {
|
|
54
|
+
Asc: "ASC",
|
|
55
|
+
Desc: "DESC",
|
|
56
|
+
} as const;
|
|
57
|
+
export type ResultOrder = (typeof ResultOrder)[keyof typeof ResultOrder];
|
|
58
|
+
|
|
59
|
+
/** orderBy for Property_Listing__c (e.g. { Listing_Price__c: { order: ResultOrder.Asc } }). */
|
|
60
|
+
export type PropertyListingsOrderBy = {
|
|
61
|
+
Listing_Price__c?: { order: ResultOrder };
|
|
62
|
+
Property__r?: { Bedrooms__c?: { order: ResultOrder } };
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Where clause: condition, or { and: conditions[] }, or { or: conditions[] }. */
|
|
66
|
+
export interface PropertyListingsQueryVariables {
|
|
67
|
+
where?:
|
|
68
|
+
| PropertyListingsWhereCondition
|
|
69
|
+
| { and: Array<PropertyListingsWhereCondition | { or: PropertyListingsWhereCondition[] }> }
|
|
70
|
+
| { or: PropertyListingsWhereCondition[] };
|
|
71
|
+
first: number;
|
|
72
|
+
after?: string | null;
|
|
73
|
+
orderBy?: PropertyListingsOrderBy | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface PropertyListingsQuery {
|
|
77
|
+
uiapi?: {
|
|
78
|
+
query?: {
|
|
79
|
+
Property_Listing__c?: {
|
|
80
|
+
edges?: Array<{
|
|
81
|
+
node?: {
|
|
82
|
+
Id: string;
|
|
83
|
+
ApiName?: string | null;
|
|
84
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
85
|
+
Listing_Price__c?: {
|
|
86
|
+
value?: number | null;
|
|
87
|
+
displayValue?: string | null;
|
|
88
|
+
} | null;
|
|
89
|
+
Listing_Status__c?: {
|
|
90
|
+
value?: string | null;
|
|
91
|
+
displayValue?: string | null;
|
|
92
|
+
} | null;
|
|
93
|
+
Property__c?: { value?: string | null; displayValue?: string | null } | null;
|
|
94
|
+
Property__r?: {
|
|
95
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
96
|
+
Address__c?: { value?: string | null; displayValue?: string | null } | null;
|
|
97
|
+
Bedrooms__c?: { value?: number | null; displayValue?: string | null } | null;
|
|
98
|
+
} | null;
|
|
99
|
+
} | null;
|
|
100
|
+
cursor?: string | null;
|
|
101
|
+
}> | null;
|
|
102
|
+
pageInfo?: {
|
|
103
|
+
hasNextPage?: boolean | null;
|
|
104
|
+
hasPreviousPage?: boolean | null;
|
|
105
|
+
startCursor?: string | null;
|
|
106
|
+
endCursor?: string | null;
|
|
107
|
+
} | null;
|
|
108
|
+
totalCount?: number | null;
|
|
109
|
+
} | null;
|
|
110
|
+
} | null;
|
|
111
|
+
} | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ---- ListingById ----
|
|
115
|
+
export interface ListingByIdQueryVariables {
|
|
116
|
+
listingId: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ListingByIdQuery {
|
|
120
|
+
uiapi?: {
|
|
121
|
+
query?: {
|
|
122
|
+
Property_Listing__c?: {
|
|
123
|
+
edges?: Array<{
|
|
124
|
+
node?: {
|
|
125
|
+
Id: string;
|
|
126
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
127
|
+
Listing_Price__c?: {
|
|
128
|
+
value?: unknown;
|
|
129
|
+
displayValue?: string | null;
|
|
130
|
+
} | null;
|
|
131
|
+
Listing_Status__c?: {
|
|
132
|
+
value?: string | null;
|
|
133
|
+
displayValue?: string | null;
|
|
134
|
+
} | null;
|
|
135
|
+
Property__c?: { value?: string | null; displayValue?: string | null } | null;
|
|
136
|
+
} | null;
|
|
137
|
+
}> | null;
|
|
138
|
+
} | null;
|
|
139
|
+
} | null;
|
|
140
|
+
} | null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ---- PropertyById ----
|
|
144
|
+
export interface PropertyByIdQueryVariables {
|
|
145
|
+
propertyId: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface PropertyByIdQuery {
|
|
149
|
+
uiapi?: {
|
|
150
|
+
query?: {
|
|
151
|
+
Property__c?: {
|
|
152
|
+
edges?: Array<{
|
|
153
|
+
node?: {
|
|
154
|
+
Id: string;
|
|
155
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
156
|
+
Address__c?: {
|
|
157
|
+
value?: string | null;
|
|
158
|
+
displayValue?: string | null;
|
|
159
|
+
} | null;
|
|
160
|
+
Type__c?: { value?: string | null; displayValue?: string | null } | null;
|
|
161
|
+
Monthly_Rent__c?: {
|
|
162
|
+
value?: unknown;
|
|
163
|
+
displayValue?: string | null;
|
|
164
|
+
} | null;
|
|
165
|
+
Bedrooms__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
166
|
+
Bathrooms__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
167
|
+
Sq_Ft__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
168
|
+
Description__c?: {
|
|
169
|
+
value?: string | null;
|
|
170
|
+
displayValue?: string | null;
|
|
171
|
+
} | null;
|
|
172
|
+
} | null;
|
|
173
|
+
}> | null;
|
|
174
|
+
} | null;
|
|
175
|
+
} | null;
|
|
176
|
+
} | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ---- PropertyImages ----
|
|
180
|
+
export interface PropertyImagesQueryVariables {
|
|
181
|
+
propertyId: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface PropertyImagesQuery {
|
|
185
|
+
uiapi?: {
|
|
186
|
+
query?: {
|
|
187
|
+
Property_Image__c?: {
|
|
188
|
+
edges?: Array<{
|
|
189
|
+
node?: {
|
|
190
|
+
Id: string;
|
|
191
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
192
|
+
Image_URL__c?: {
|
|
193
|
+
value?: string | null;
|
|
194
|
+
displayValue?: string | null;
|
|
195
|
+
} | null;
|
|
196
|
+
Image_Type__c?: {
|
|
197
|
+
value?: string | null;
|
|
198
|
+
displayValue?: string | null;
|
|
199
|
+
} | null;
|
|
200
|
+
Display_Order__c?: {
|
|
201
|
+
value?: unknown;
|
|
202
|
+
displayValue?: string | null;
|
|
203
|
+
} | null;
|
|
204
|
+
Alt_Text__c?: {
|
|
205
|
+
value?: string | null;
|
|
206
|
+
displayValue?: string | null;
|
|
207
|
+
} | null;
|
|
208
|
+
} | null;
|
|
209
|
+
}> | null;
|
|
210
|
+
} | null;
|
|
211
|
+
} | null;
|
|
212
|
+
} | null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ---- PropertyCosts ----
|
|
216
|
+
export interface PropertyCostsQueryVariables {
|
|
217
|
+
propertyId: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface PropertyCostsQuery {
|
|
221
|
+
uiapi?: {
|
|
222
|
+
query?: {
|
|
223
|
+
Property_Cost__c?: {
|
|
224
|
+
edges?: Array<{
|
|
225
|
+
node?: {
|
|
226
|
+
Id: string;
|
|
227
|
+
Cost_Category__c?: {
|
|
228
|
+
value?: string | null;
|
|
229
|
+
displayValue?: string | null;
|
|
230
|
+
} | null;
|
|
231
|
+
Cost_Amount__c?: {
|
|
232
|
+
value?: unknown;
|
|
233
|
+
displayValue?: string | null;
|
|
234
|
+
} | null;
|
|
235
|
+
Cost_Date__c?: {
|
|
236
|
+
value?: string | null;
|
|
237
|
+
displayValue?: string | null;
|
|
238
|
+
} | null;
|
|
239
|
+
Description__c?: {
|
|
240
|
+
value?: string | null;
|
|
241
|
+
displayValue?: string | null;
|
|
242
|
+
} | null;
|
|
243
|
+
Vendor__c?: {
|
|
244
|
+
value?: string | null;
|
|
245
|
+
displayValue?: string | null;
|
|
246
|
+
} | null;
|
|
247
|
+
} | null;
|
|
248
|
+
}> | null;
|
|
249
|
+
} | null;
|
|
250
|
+
} | null;
|
|
251
|
+
} | null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ---- PropertyFeatures ----
|
|
255
|
+
export interface PropertyFeaturesQueryVariables {
|
|
256
|
+
propertyId: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface PropertyFeaturesQuery {
|
|
260
|
+
uiapi?: {
|
|
261
|
+
query?: {
|
|
262
|
+
Property_Feature__c?: {
|
|
263
|
+
edges?: Array<{
|
|
264
|
+
node?: {
|
|
265
|
+
Id: string;
|
|
266
|
+
Name?: { value?: string | null; displayValue?: string | null } | null;
|
|
267
|
+
Feature_Category__c?: {
|
|
268
|
+
value?: string | null;
|
|
269
|
+
displayValue?: string | null;
|
|
270
|
+
} | null;
|
|
271
|
+
Description__c?: {
|
|
272
|
+
value?: string | null;
|
|
273
|
+
displayValue?: string | null;
|
|
274
|
+
} | null;
|
|
275
|
+
} | null;
|
|
276
|
+
}> | null;
|
|
277
|
+
} | null;
|
|
278
|
+
} | null;
|
|
279
|
+
} | null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ---- GetUserInfo ----
|
|
283
|
+
export interface GetUserInfoQuery {
|
|
284
|
+
uiapi?: {
|
|
285
|
+
query?: {
|
|
286
|
+
User?: {
|
|
287
|
+
edges?: Array<{
|
|
288
|
+
node?: {
|
|
289
|
+
Id: string;
|
|
290
|
+
Name?: { value?: string | null } | null;
|
|
291
|
+
} | null;
|
|
292
|
+
}> | null;
|
|
293
|
+
} | null;
|
|
294
|
+
} | null;
|
|
295
|
+
} | null;
|
|
296
|
+
}
|
package/dist/force-app/main/default/webapplications/appreactsampleb2x/src/api/graphqlClient.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GraphQL client
|
|
2
|
+
* Thin GraphQL client: getDataSDK + data.graphql with centralized error handling.
|
|
3
|
+
* Use with gql-tagged queries and generated operation types for type-safe calls.
|
|
3
4
|
*/
|
|
4
5
|
import { getDataSDK } from "@salesforce/sdk-data";
|
|
5
6
|
|
|
6
|
-
export async function executeGraphQL<
|
|
7
|
-
query: string,
|
|
8
|
-
variables?:
|
|
9
|
-
): Promise<
|
|
7
|
+
export async function executeGraphQL<TData, TVariables = Record<string, unknown>>(
|
|
8
|
+
query: string | { kind: string; definitions: unknown[] },
|
|
9
|
+
variables?: TVariables,
|
|
10
|
+
): Promise<TData> {
|
|
10
11
|
const data = await getDataSDK();
|
|
11
|
-
|
|
12
|
+
// SDK types graphql() first param as string; at runtime it may accept gql DocumentNode too
|
|
13
|
+
const response = await data.graphql?.<TData>(
|
|
14
|
+
query as unknown as string,
|
|
15
|
+
variables as Record<string, unknown>,
|
|
16
|
+
);
|
|
12
17
|
if (response?.errors?.length) {
|
|
13
18
|
const msg = response.errors.map((e) => e.message).join("; ");
|
|
14
19
|
throw new Error(`GraphQL Error: ${msg}`);
|
|
15
20
|
}
|
|
16
|
-
return (response?.data ?? {}) as
|
|
21
|
+
return (response?.data ?? {}) as TData;
|
|
17
22
|
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Maintenance_Request__c: list via GraphQL, create via createRecord.
|
|
3
3
|
*/
|
|
4
4
|
import { createRecord } from "@salesforce/webapp-experimental/api";
|
|
5
|
-
import {
|
|
5
|
+
import { gql } from "@salesforce/sdk-data";
|
|
6
|
+
import type {
|
|
7
|
+
MaintenanceRequestsQuery,
|
|
8
|
+
MaintenanceRequestsQueryVariables,
|
|
9
|
+
} from "@/api/graphql-operations-types.js";
|
|
10
|
+
import { executeGraphQL } from "@/api/graphqlClient.js";
|
|
6
11
|
|
|
7
12
|
const OBJECT_API_NAME = "Maintenance_Request__c";
|
|
8
13
|
|
|
@@ -15,6 +20,8 @@ export interface MaintenanceRequestSummary {
|
|
|
15
20
|
priority: string | null;
|
|
16
21
|
status: string | null;
|
|
17
22
|
dateRequested: string | null;
|
|
23
|
+
/** Tenant / user the request is assigned to (from User__r lookup). */
|
|
24
|
+
tenantName: string | null;
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
function pick<T>(obj: T, key: keyof T): unknown {
|
|
@@ -30,33 +37,47 @@ function str(x: unknown): string | null {
|
|
|
30
37
|
return String(x);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
/** Node shape from MaintenanceRequests query (matches graphql-operations-types). */
|
|
41
|
+
interface MaintenanceRequestNode {
|
|
34
42
|
Id: string;
|
|
35
43
|
ApiName?: string | null;
|
|
36
44
|
Name?: { value?: unknown; displayValue?: string | null } | null;
|
|
37
|
-
Title__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
38
45
|
Description__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
39
46
|
Type__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
40
47
|
Priority__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
41
48
|
Status__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
42
|
-
|
|
43
|
-
};
|
|
49
|
+
Scheduled__c?: { value?: unknown; displayValue?: string | null } | null;
|
|
50
|
+
User__r?: { Name?: { value?: unknown; displayValue?: string | null } | null } | null;
|
|
51
|
+
}
|
|
44
52
|
|
|
45
|
-
function nodeToSummary(node:
|
|
53
|
+
function nodeToSummary(node: MaintenanceRequestNode): MaintenanceRequestSummary {
|
|
54
|
+
const desc = str(pick(node, "Description__c"));
|
|
55
|
+
const userRef = node.User__r as
|
|
56
|
+
| { Name?: { value?: unknown; displayValue?: string | null } }
|
|
57
|
+
| undefined;
|
|
58
|
+
const tenantName =
|
|
59
|
+
str(
|
|
60
|
+
userRef?.Name && typeof userRef.Name === "object"
|
|
61
|
+
? (userRef.Name as { value?: unknown }).value
|
|
62
|
+
: null,
|
|
63
|
+
) ??
|
|
64
|
+
str(userRef?.Name?.displayValue) ??
|
|
65
|
+
null;
|
|
46
66
|
return {
|
|
47
67
|
id: node.Id,
|
|
48
68
|
name:
|
|
49
69
|
str(pick(node, "Name")) ?? str((node.Name as { displayValue?: string | null })?.displayValue),
|
|
50
|
-
title:
|
|
51
|
-
description:
|
|
70
|
+
title: desc,
|
|
71
|
+
description: desc,
|
|
52
72
|
type: str(pick(node, "Type__c")),
|
|
53
73
|
priority: str(pick(node, "Priority__c")),
|
|
54
74
|
status: str(pick(node, "Status__c")),
|
|
55
|
-
dateRequested: str(pick(node, "
|
|
75
|
+
dateRequested: str(pick(node, "Scheduled__c")),
|
|
76
|
+
tenantName,
|
|
56
77
|
};
|
|
57
78
|
}
|
|
58
79
|
|
|
59
|
-
const MAINTENANCE_REQUESTS_QUERY =
|
|
80
|
+
const MAINTENANCE_REQUESTS_QUERY = gql`
|
|
60
81
|
query MaintenanceRequests($first: Int!, $after: String) {
|
|
61
82
|
uiapi {
|
|
62
83
|
query {
|
|
@@ -69,10 +90,6 @@ const MAINTENANCE_REQUESTS_QUERY = /* GraphQL */ `
|
|
|
69
90
|
value
|
|
70
91
|
displayValue
|
|
71
92
|
}
|
|
72
|
-
Title__c {
|
|
73
|
-
value
|
|
74
|
-
displayValue
|
|
75
|
-
}
|
|
76
93
|
Description__c {
|
|
77
94
|
value
|
|
78
95
|
displayValue
|
|
@@ -89,10 +106,16 @@ const MAINTENANCE_REQUESTS_QUERY = /* GraphQL */ `
|
|
|
89
106
|
value
|
|
90
107
|
displayValue
|
|
91
108
|
}
|
|
92
|
-
|
|
109
|
+
Scheduled__c {
|
|
93
110
|
value
|
|
94
111
|
displayValue
|
|
95
112
|
}
|
|
113
|
+
User__r {
|
|
114
|
+
Name {
|
|
115
|
+
value
|
|
116
|
+
displayValue
|
|
117
|
+
}
|
|
118
|
+
}
|
|
96
119
|
}
|
|
97
120
|
cursor
|
|
98
121
|
}
|
|
@@ -106,28 +129,19 @@ const MAINTENANCE_REQUESTS_QUERY = /* GraphQL */ `
|
|
|
106
129
|
}
|
|
107
130
|
`;
|
|
108
131
|
|
|
109
|
-
interface MaintenanceRequestGraphQLResponse {
|
|
110
|
-
uiapi?: {
|
|
111
|
-
query?: {
|
|
112
|
-
Maintenance_Request__c?: {
|
|
113
|
-
edges?: ({ node?: Node | null } | null)[] | null;
|
|
114
|
-
} | null;
|
|
115
|
-
} | null;
|
|
116
|
-
} | null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
132
|
export async function queryMaintenanceRequests(
|
|
120
133
|
first: number = 50,
|
|
121
134
|
after: string | null = null,
|
|
122
135
|
): Promise<MaintenanceRequestSummary[]> {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
const variables: MaintenanceRequestsQueryVariables = { first, after: after ?? null };
|
|
137
|
+
const response = await executeGraphQL<
|
|
138
|
+
MaintenanceRequestsQuery,
|
|
139
|
+
MaintenanceRequestsQueryVariables
|
|
140
|
+
>(MAINTENANCE_REQUESTS_QUERY, variables);
|
|
127
141
|
const edges = response.uiapi?.query?.Maintenance_Request__c?.edges ?? [];
|
|
128
142
|
const list: MaintenanceRequestSummary[] = [];
|
|
129
143
|
for (const e of edges) {
|
|
130
|
-
if (e?.node) list.push(nodeToSummary(e.node));
|
|
144
|
+
if (e?.node) list.push(nodeToSummary(e.node as MaintenanceRequestNode));
|
|
131
145
|
}
|
|
132
146
|
// Sort by date requested descending (newest first)
|
|
133
147
|
list.sort((a, b) => {
|
|
@@ -139,12 +153,11 @@ export async function queryMaintenanceRequests(
|
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
export interface CreateMaintenanceRequestInput {
|
|
142
|
-
|
|
143
|
-
Description__c?: string | null;
|
|
156
|
+
Description__c: string;
|
|
144
157
|
Type__c?: string | null;
|
|
145
158
|
Priority__c?: string;
|
|
146
159
|
Status__c?: string;
|
|
147
|
-
|
|
160
|
+
Scheduled__c?: string | null;
|
|
148
161
|
}
|
|
149
162
|
|
|
150
163
|
function getRecordIdFromResponse(result: Record<string, unknown>): string {
|
|
@@ -159,16 +172,15 @@ function getRecordIdFromResponse(result: Record<string, unknown>): string {
|
|
|
159
172
|
export async function createMaintenanceRequest(
|
|
160
173
|
input: CreateMaintenanceRequestInput,
|
|
161
174
|
): Promise<{ id: string }> {
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
175
|
+
const description = input.Description__c?.trim();
|
|
176
|
+
if (!description) throw new Error("Description is required");
|
|
164
177
|
const fields: Record<string, unknown> = {
|
|
165
|
-
|
|
178
|
+
Description__c: description,
|
|
166
179
|
Priority__c: input.Priority__c?.trim() || "Standard",
|
|
167
180
|
Status__c: input.Status__c?.trim() || "New",
|
|
168
181
|
};
|
|
169
|
-
if (input.Description__c?.trim()) fields.Description__c = input.Description__c.trim();
|
|
170
182
|
if (input.Type__c?.trim()) fields.Type__c = input.Type__c.trim();
|
|
171
|
-
if (input.
|
|
183
|
+
if (input.Scheduled__c?.trim()) fields.Scheduled__c = input.Scheduled__c.trim();
|
|
172
184
|
const result = (await createRecord(OBJECT_API_NAME, fields)) as unknown as Record<
|
|
173
185
|
string,
|
|
174
186
|
unknown
|