@7365admin1/layer-common 4.90.1 → 4.90.2-staging.484

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/assets/css/primitives.css +57 -0
  3. package/assets/css/robot-hero.css +3 -0
  4. package/assets/css/screens.css +8 -4
  5. package/components/AccessCardDetailsDialog.vue +57 -4
  6. package/components/AccessCardPreviewDialog.vue +291 -50
  7. package/components/AppSelect.vue +143 -4
  8. package/components/BuildingUnitFormEdit.vue +6 -0
  9. package/components/BuildingUnitManagement.vue +298 -0
  10. package/components/ClientMain.vue +56 -14
  11. package/components/Dialog/UpdateMoreAction.vue +11 -1
  12. package/components/DocumentForm.vue +407 -112
  13. package/components/DocumentManagement.vue +213 -12
  14. package/components/Facility/BookingSetup.vue +63 -0
  15. package/components/HidAccessLogDashboard.vue +74 -17
  16. package/components/HidAccessPermissions.vue +424 -0
  17. package/components/HidIntercomManagement.vue +183 -14
  18. package/components/HidProfileQrCode.vue +332 -0
  19. package/components/HidQrCodeConfiguration.vue +17 -195
  20. package/components/HidReaderManagement.vue +398 -0
  21. package/components/HidReaderUserRoster.vue +44 -3
  22. package/components/HidUserEnrollment.vue +2239 -276
  23. package/components/InvitationClientForm.vue +19 -1
  24. package/components/MemberInformation.vue +4 -4
  25. package/components/PassInformation.vue +2 -2
  26. package/components/TableMain.vue +22 -7
  27. package/components/VisitorForm.vue +65 -19
  28. package/components/VisitorManagement.vue +267 -5
  29. package/composables/useDocument.ts +7 -0
  30. package/composables/useFacility.ts +11 -0
  31. package/composables/useHidAmico.ts +165 -0
  32. package/composables/useHidNavigation.ts +25 -1
  33. package/composables/useHidReaderSelection.ts +50 -0
  34. package/composables/useMember.ts +12 -0
  35. package/composables/useNFCPatrolReportFilters.ts +21 -3
  36. package/composables/useNFCPatrolRoute.ts +8 -1
  37. package/composables/usePeople.ts +19 -0
  38. package/composables/useServiceProvider.ts +45 -2
  39. package/composables/useSiteCategory.ts +45 -0
  40. package/package.json +1 -1
  41. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  42. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  43. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  44. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  45. package/types/document.d.ts +14 -0
  46. package/types/facility.d.ts +4 -0
  47. package/types/member.d.ts +4 -0
  48. package/types/people.d.ts +28 -1
  49. package/types/service-provider.d.ts +5 -0
  50. package/types/site.d.ts +7 -1
  51. package/utils/hid-enrolment-subject.ts +344 -0
  52. package/utils/hid-permission-assignments.ts +198 -0
  53. package/utils/hid-reader-selection.ts +52 -0
  54. package/utils/occupancy-role.ts +109 -0
  55. package/utils/service-type.ts +30 -0
@@ -6,6 +6,7 @@ export default function useDocument() {
6
6
  type = "all",
7
7
  site = "",
8
8
  parentId = "",
9
+ expiry = "all",
9
10
  }: {
10
11
  page?: number;
11
12
  search?: string;
@@ -13,6 +14,11 @@ export default function useDocument() {
13
14
  type?: string;
14
15
  site?: string;
15
16
  parentId?: string;
17
+ /**
18
+ * Which tab is asking: "active" for Documents, "expired" for
19
+ * Document (Expired). Defaults to "all" so existing callers are unaffected.
20
+ */
21
+ expiry?: string;
16
22
  } = {}) {
17
23
  const query: Record<string, any> = {
18
24
  page,
@@ -21,6 +27,7 @@ export default function useDocument() {
21
27
  type,
22
28
  site,
23
29
  parentId,
30
+ expiry,
24
31
  };
25
32
 
26
33
  return useNuxtApp().$api<Record<string, any>>(`/api/documents`, {
@@ -76,6 +76,8 @@ export default function usetFacility() {
76
76
  hourInterval?: number;
77
77
  isBookingFeeEnabled: boolean;
78
78
  isGuestEnabled: boolean;
79
+ isResidentChecklistEnabled: boolean;
80
+ isSecurityChecklistEnabled: boolean;
79
81
  bookingAmount: number | null;
80
82
  peakBookingFeeAmount?: number | null;
81
83
  bookingFeeGuestAmount?: number | null;
@@ -173,6 +175,8 @@ export default function usetFacility() {
173
175
  hourInterval = 1,
174
176
  isBookingFeeEnabled = false,
175
177
  isGuestEnabled = false,
178
+ isResidentChecklistEnabled = false,
179
+ isSecurityChecklistEnabled = false,
176
180
  bookingAmount = 0,
177
181
  peakBookingFeeAmount = 0,
178
182
  bookingFeeGuestAmount = 0,
@@ -236,6 +240,13 @@ export default function usetFacility() {
236
240
  this.hourInterval = hourInterval;
237
241
  this.isBookingFeeEnabled = isBookingFeeEnabled;
238
242
  this.isGuestEnabled = isGuestEnabled;
243
+ // Exactly one owner, always. `isResidentChecklistEnabled` is the flag
244
+ // the apps gate on, so it decides, and security is its complement —
245
+ // stored rather than computed so each app can read its own flag without
246
+ // knowing the rule. A facility predating both fields lands on security,
247
+ // which is how every one of them already behaved.
248
+ this.isResidentChecklistEnabled = isResidentChecklistEnabled === true;
249
+ this.isSecurityChecklistEnabled = !this.isResidentChecklistEnabled;
239
250
  this.bookingAmount = bookingAmount;
240
251
  this.peakBookingFeeAmount = peakBookingFeeAmount;
241
252
  this.bookingFeeGuestAmount = bookingFeeGuestAmount;
@@ -28,6 +28,22 @@ export type HidReaderPayload = {
28
28
  lastCallbackType?: string;
29
29
  };
30
30
 
31
+ export type HidProfileQr = {
32
+ readerId: string;
33
+ userId: string;
34
+ memberId: string;
35
+ hidUserId: string;
36
+ registration: string;
37
+ readerName: string;
38
+ portalName: string;
39
+ qrEnabled: boolean;
40
+ issued: boolean;
41
+ qrValue: string;
42
+ issuedAt: string;
43
+ /** null when the permission lookup itself failed, so "unknown" stays distinct from "no". */
44
+ assigned: boolean | null;
45
+ };
46
+
31
47
  type HidIdentityPayload = {
32
48
  site?: string;
33
49
  hidUserId?: string | number;
@@ -139,6 +155,28 @@ export type HidSipAccountData = {
139
155
  provisionedAt: string;
140
156
  };
141
157
 
158
+ /** One row of the site's SIP account list - who owns the extension, never its password. */
159
+ export type HidSipAccountListItem = {
160
+ _id: string;
161
+ userId: string;
162
+ name: string;
163
+ email: string;
164
+ /**
165
+ * What the owner is called after their name on the contact list: their
166
+ * "Blk 1/Level 1/Unit 1" when they live here, and their membership type -
167
+ * "Security Agency" - when they do not. "" only when the site knows neither.
168
+ *
169
+ * Optional because an API still on the `@7365admin1/core` release that
170
+ * predates it answers without the field; the contact picker falls back to the
171
+ * bare name rather than showing a dangling separator.
172
+ */
173
+ unitLabel?: string;
174
+ extension: string;
175
+ username: string;
176
+ status: string;
177
+ provisionedAt: string;
178
+ };
179
+
142
180
  /**
143
181
  * True only for the specific validation error an API that predates core #1878
144
182
  * returns when the discover body carries `site`. Deliberately narrow: after
@@ -166,6 +204,36 @@ export default function useHidAmico() {
166
204
  });
167
205
  }
168
206
 
207
+ /**
208
+ * The signed-in member's own QR code on one reader.
209
+ *
210
+ * No user id in the path: the server takes the caller from the session, so
211
+ * these cannot be pointed at somebody else. `assigned` in the response says
212
+ * whether the HID permissions screen actually admits this member to the
213
+ * reader - issuing a code does not grant access, and the screen has to be
214
+ * able to say so.
215
+ */
216
+ function getProfileQr(readerId: string) {
217
+ return useNuxtApp().$api<{ data: HidProfileQr }>(
218
+ `${basePath}/readers/${readerId}/profile-qr`,
219
+ { method: "GET" },
220
+ );
221
+ }
222
+
223
+ function issueProfileQr(readerId: string) {
224
+ return useNuxtApp().$api<{ data: HidProfileQr }>(
225
+ `${basePath}/readers/${readerId}/profile-qr`,
226
+ { method: "POST" },
227
+ );
228
+ }
229
+
230
+ function deleteProfileQr(readerId: string) {
231
+ return useNuxtApp().$api<{ data: HidProfileQr }>(
232
+ `${basePath}/readers/${readerId}/profile-qr`,
233
+ { method: "DELETE" },
234
+ );
235
+ }
236
+
169
237
  function createReader(payload: HidReaderPayload) {
170
238
  return useNuxtApp().$api<HidApiRecord>(`${basePath}/readers`, {
171
239
  method: "POST",
@@ -257,6 +325,36 @@ export default function useHidAmico() {
257
325
  });
258
326
  }
259
327
 
328
+ /**
329
+ * Which credentials a reader accepts at the door.
330
+ *
331
+ * Separate from `setReaderConfiguration` on purpose. That one is the generic
332
+ * configuration endpoint, gated by an allowlist of writable objects; this is
333
+ * a dedicated route that validates the four methods against the reader's own
334
+ * `capabilities` and confirms the write by reading the device back, so a
335
+ * refusal here names the credential the hardware would not take.
336
+ */
337
+ function setReaderIdentificationMethods(readerId: string, payload: HidApiRecord) {
338
+ return useNuxtApp().$api<HidApiRecord>(
339
+ `${basePath}/readers/${readerId}/identification-methods`,
340
+ { method: "PUT", body: payload },
341
+ );
342
+ }
343
+
344
+ /**
345
+ * Put a reader back to the settings iService holds for it.
346
+ *
347
+ * A POST rather than a GET because it WRITES: reading the reader's
348
+ * configuration is only the first half, and anything that drifted is
349
+ * re-applied before this returns.
350
+ */
351
+ function reconcileReaderIdentificationMethods(readerId: string) {
352
+ return useNuxtApp().$api<HidApiRecord>(
353
+ `${basePath}/readers/${readerId}/identification-methods/reconcile`,
354
+ { method: "POST" },
355
+ );
356
+ }
357
+
260
358
  function getIdentities(readerId: string, query: HidApiRecord = {}) {
261
359
  return useNuxtApp().$api<HidApiRecord>(`${basePath}/readers/${readerId}/identities`, {
262
360
  method: "GET",
@@ -414,6 +512,27 @@ export default function useHidAmico() {
414
512
  );
415
513
  }
416
514
 
515
+ function getUserPasswordStatus(readerId: string, hidUserId: string | number) {
516
+ return useNuxtApp().$api<HidApiRecord>(
517
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
518
+ { method: "GET" },
519
+ );
520
+ }
521
+
522
+ function setUserPassword(readerId: string, hidUserId: string | number, password: string) {
523
+ return useNuxtApp().$api<HidApiRecord>(
524
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
525
+ { method: "PUT", body: { password } },
526
+ );
527
+ }
528
+
529
+ function deleteUserPassword(readerId: string, hidUserId: string | number) {
530
+ return useNuxtApp().$api<HidApiRecord>(
531
+ `${basePath}/readers/${readerId}/users/${hidUserId}/password`,
532
+ { method: "DELETE" },
533
+ );
534
+ }
535
+
417
536
  function deleteUserPin(readerId: string, hidUserId: string | number) {
418
537
  return useNuxtApp().$api<{ data: { pinEnrolled: boolean } }>(
419
538
  `${basePath}/readers/${readerId}/users/${hidUserId}/pin`,
@@ -474,6 +593,42 @@ export default function useHidAmico() {
474
593
  );
475
594
  }
476
595
 
596
+ /**
597
+ * The site's SIP accounts for the intercom contact picker. Site-scoped only:
598
+ * the organisation never decided who may read this — the site guard does —
599
+ * and sending one narrowed the list on a customer site whose accounts were
600
+ * provisioned by a managing agent.
601
+ */
602
+ function getSipAccounts(siteId: string) {
603
+ return useNuxtApp().$api<{ data: HidSipAccountListItem[] }>(
604
+ `${basePath}/sites/${siteId}/intercom/sip-accounts`,
605
+ { method: "GET" },
606
+ );
607
+ }
608
+
609
+ /**
610
+ * Wake the resident's phone for a call the web phone has just placed.
611
+ *
612
+ * The SIP INVITE is the call and travels over the WebSocket, not through the
613
+ * API; this only rings the resident's mobile so somebody is there to answer
614
+ * it. It is therefore fired after the INVITE and never awaited in a way that
615
+ * could fail the call — see `startWebCall` in `HidIntercomManagement.vue`.
616
+ *
617
+ * `notified: false` with a reason is a normal response, not an error: staff
618
+ * extensions and external SIP addresses have no resident behind them.
619
+ */
620
+ function notifyIntercomCall(
621
+ siteId: string,
622
+ payload: { orgId: string; destination: string; callId: string; readerId?: string },
623
+ ) {
624
+ return useNuxtApp().$api<{
625
+ data: { notified: boolean; delivered?: number; reason?: string };
626
+ }>(
627
+ `${basePath}/sites/${siteId}/intercom/notify-call`,
628
+ { method: "POST", body: payload },
629
+ );
630
+ }
631
+
477
632
  function getPermissionCandidates(
478
633
  siteId: string,
479
634
  query: {
@@ -505,6 +660,9 @@ export default function useHidAmico() {
505
660
 
506
661
  return {
507
662
  getReaders,
663
+ getProfileQr,
664
+ issueProfileQr,
665
+ deleteProfileQr,
508
666
  discoverReader,
509
667
  createReader,
510
668
  updateReader,
@@ -519,6 +677,8 @@ export default function useHidAmico() {
519
677
  issueVisitorQr,
520
678
  getReaderConfiguration,
521
679
  setReaderConfiguration,
680
+ setReaderIdentificationMethods,
681
+ reconcileReaderIdentificationMethods,
522
682
  getLogs,
523
683
  setUserImage,
524
684
  deleteUserImage,
@@ -530,6 +690,9 @@ export default function useHidAmico() {
530
690
  getUserPinStatus,
531
691
  setUserPin,
532
692
  deleteUserPin,
693
+ getUserPasswordStatus,
694
+ setUserPassword,
695
+ deleteUserPassword,
533
696
  getIdentities,
534
697
  getReaderUsers,
535
698
  getReaderAccessLogs,
@@ -540,6 +703,8 @@ export default function useHidAmico() {
540
703
  makeIntercomCall,
541
704
  finalizeIntercomCall,
542
705
  ensureSipAccount,
706
+ getSipAccounts,
707
+ notifyIntercomCall,
543
708
  getSitePermissions,
544
709
  getPermissionCandidates,
545
710
  updateSitePermissions,
@@ -46,9 +46,33 @@ export default function useHidNavigation() {
46
46
  },
47
47
  },
48
48
  {
49
+ // "HID Reader Users" now points at `access-mgmt/administrator`, not at
50
+ // `access-mgmt/hid-users`.
51
+ //
52
+ // Both routes mount a roster of the reader's users, but only this one
53
+ // can act on them. `administrator` renders HidUserEnrollment WITHOUT
54
+ // `card-management`, and that prop is what gates the Enroll action:
55
+ // <template v-if="!props.cardManagement" #actions>
56
+ // `hid-users` renders HidReaderUserRoster, which is read-only apart
57
+ // from PIN management. So the menu entry with this name used to lead
58
+ // to the screen that cannot enrol, while the screen that can was
59
+ // reachable only by typing the URL.
60
+ //
61
+ // `hid-users` is left in place and simply unlisted - the same state
62
+ // `administrator` was in - so any existing link to it still resolves.
49
63
  title: "HID Reader Users",
50
64
  route: {
51
- name: "org-site-access-mgmt-hid-users",
65
+ name: "org-site-access-mgmt-administrator",
66
+ params: { org, site },
67
+ },
68
+ },
69
+ {
70
+ // The signed-in member's own pass, not somebody else's. Every other
71
+ // entry in this group acts on a resident or a visitor; this one has
72
+ // no subject but the caller.
73
+ title: "HID QR Code",
74
+ route: {
75
+ name: "org-site-access-mgmt-hid-qr-code",
52
76
  params: { org, site },
53
77
  },
54
78
  },
@@ -0,0 +1,50 @@
1
+ import {
2
+ EMPTY_HID_READER_CHOICE,
3
+ resolveHidReaderId,
4
+ type HidReaderChoice,
5
+ } from "../utils/hid-reader-selection";
6
+
7
+ /**
8
+ * ONE HID READER CHOICE, SHARED BY EVERY HID SCREEN.
9
+ *
10
+ * Declared at MODULE scope on purpose. Each screen held its own `ref("")`, and
11
+ * because the HID screens are separate pages the ref was rebuilt on every
12
+ * navigation — HID Reader Users, HID Cards, Access Logs and HID QR Code each
13
+ * reset to the first reader no matter what had just been picked next door.
14
+ *
15
+ * A module-scoped ref is enough because moving between those pages is a ROUTE
16
+ * change, not a page load: the menu's items carry a `route` and
17
+ * `NavigationItem.vue` renders them through `:to`, so vue-router handles them
18
+ * and this module is never re-evaluated.
19
+ *
20
+ * Deliberately NOT persisted. `localStorage` would carry the choice through a
21
+ * hard refresh as well, which is a real but much smaller benefit than the
22
+ * navigation case, and it is worth adding only once somebody has felt the
23
+ * absence. See `utils/hid-reader-selection.ts` for the staleness rule that
24
+ * would have to hold either way.
25
+ *
26
+ * Intercom keeps its own reader and is not wired to this. Its question is which
27
+ * panel you are calling, not which door you are administering, and joining them
28
+ * would mean switching reader on Access Logs changed who you would dial.
29
+ */
30
+ const choice = ref<HidReaderChoice>({ ...EMPTY_HID_READER_CHOICE });
31
+
32
+ export default function useHidReaderSelection() {
33
+ /** Remember a choice. The site travels with it; an id alone means nothing. */
34
+ function selectHidReader(siteId: string, readerId: string) {
35
+ choice.value = { siteId: String(siteId ?? ""), readerId: String(readerId ?? "") };
36
+ }
37
+
38
+ /**
39
+ * The reader this screen should show, given the readers it just loaded.
40
+ *
41
+ * Call it after the reader list arrives, and write the answer back with
42
+ * `selectHidReader` so the screens agree on what "current" means even when
43
+ * one of them had to fall back to the first reader.
44
+ */
45
+ function resolveForSite(siteId: string, readers: readonly { _id?: unknown }[]) {
46
+ return resolveHidReaderId(siteId, readers, choice.value);
47
+ }
48
+
49
+ return { choice, selectHidReader, resolveForSite };
50
+ }
@@ -70,6 +70,8 @@ export default function useMember() {
70
70
  status = "active",
71
71
  siteId = "",
72
72
  roleState = "",
73
+ /** A building unit id, or "none": members on no unit yet. */
74
+ unit = "",
73
75
  people = false,
74
76
  } = {}) {
75
77
  const query: Record<string, any> = { page, limit, type, status };
@@ -83,6 +85,7 @@ export default function useMember() {
83
85
  if (user) query.user = user;
84
86
  if (org) query.org = org;
85
87
  if (siteId) query.siteId = siteId;
88
+ if (unit) query.unit = unit;
86
89
  return useNuxtApp().$api<Record<string, any>>("/api/members", {
87
90
  method: "GET",
88
91
  query,
@@ -158,6 +161,14 @@ export default function useMember() {
158
161
  });
159
162
  }
160
163
 
164
+ /** Attach a member to a building unit, or detach them (`unit` ""). */
165
+ function updateMemberUnit(id: string, unit: string) {
166
+ return useNuxtApp().$api<Record<string, any>>("/api/members/unit", {
167
+ method: "PUT",
168
+ body: { id, unit },
169
+ });
170
+ }
171
+
161
172
  function getByUserTypeOrg(user: string, type: string, org: string) {
162
173
  return useNuxtApp().$api<TMember>(
163
174
  `/api/members/user/${user}/app/${type}/org`,
@@ -226,6 +237,7 @@ export default function useMember() {
226
237
  undoCrossSiteRoleFix,
227
238
  getSiteAccess,
228
239
  saveSiteAccess,
240
+ updateMemberUnit,
229
241
  members,
230
242
  member,
231
243
  page,
@@ -31,9 +31,27 @@ export function useNFCPatrolReportFilters(site: string) {
31
31
  loading.value = true;
32
32
 
33
33
  try {
34
- const response = await getPatrolRoutes({ site, page: 1, limit: 100 });
35
- const routes = (response.items ?? []).map((route: Record<string, any>) => ({
36
- title: route.name,
34
+ // Deleted routes too, labelled, so their past patrols can still be
35
+ // reported on. An API from before route deletion refuses the parameter
36
+ // with a 400: ask again without it, and the list is what it was.
37
+ const response = await getPatrolRoutes({
38
+ site,
39
+ page: 1,
40
+ limit: 100,
41
+ includeDeleted: true,
42
+ }).catch((error: any) => {
43
+ const status = Number(error?.statusCode ?? error?.response?.status ?? 0);
44
+ if (status !== 400) throw error;
45
+ return getPatrolRoutes({ site, page: 1, limit: 100 });
46
+ });
47
+ const items: Array<Record<string, any>> = response.items ?? [];
48
+ const isDeleted = (route: Record<string, any>) => route.status === "Deleted";
49
+ // Routes still in use first, so the report opens on one of them.
50
+ const routes = [
51
+ ...items.filter((route) => !isDeleted(route)),
52
+ ...items.filter(isDeleted),
53
+ ].map((route) => ({
54
+ title: isDeleted(route) ? `${route.name} (deleted)` : route.name,
37
55
  value: route._id,
38
56
  startTimes: route.startTimes ?? [],
39
57
  }));
@@ -4,17 +4,24 @@ export default function useNFCPatrolRoute() {
4
4
  limit = 20,
5
5
  site = "",
6
6
  search = "",
7
+ includeDeleted = false,
7
8
  } = {}) {
8
9
  const query: Record<string, any> = {
9
10
  page,
10
11
  limit,
11
12
  site,
12
13
  };
13
-
14
+
14
15
  // Only include search parameter if it has a value
15
16
  if (search) {
16
17
  query.search = search;
17
18
  }
19
+
20
+ // Deleted routes are left out unless asked for; only the patrol log
21
+ // report's route picker asks, so their past patrols stay reachable.
22
+ if (includeDeleted) {
23
+ query.includeDeleted = true;
24
+ }
18
25
 
19
26
  return useNuxtApp().$api<Record<string, any>>(`/api/nfc-patrol-route`, {
20
27
  method: "GET",
@@ -115,6 +115,24 @@ export default function () {
115
115
  });
116
116
  }
117
117
 
118
+ /**
119
+ * The blocks, levels and units at a site that actually have an occupant.
120
+ * The other half of the unit picker: this narrows the cascade, then
121
+ * `getPeopleByUnit` answers "which person in this unit?".
122
+ */
123
+ async function getOccupiedStructure(
124
+ site: string,
125
+ { type = "", status = "active", block = "", level = "" } = {}
126
+ ) {
127
+ return await useNuxtApp().$api<Record<string, any>>(
128
+ `/api/people/site/${site}/occupied-structure`,
129
+ {
130
+ method: "GET",
131
+ query: { type, status, block, level },
132
+ }
133
+ );
134
+ }
135
+
118
136
  async function getPeopleByUnit(
119
137
  _id: string,
120
138
  { status = "active", type = "" } = {}
@@ -148,6 +166,7 @@ export default function () {
148
166
  findPersonByPlateNumberMultipleResult,
149
167
  findPersonByContact,
150
168
  getPeopleByUnit,
169
+ getOccupiedStructure,
151
170
  searchCompanyList,
152
171
  findUsersByPlateNumber,
153
172
  reviewResidentPerson,
@@ -15,6 +15,21 @@ export type TSiteProviderMember = {
15
15
  lastLoginAt?: string | null;
16
16
  /** a subcontractor: the provider that brought its company onto the site */
17
17
  invitedVia?: string;
18
+ /** The building unit this person is attached to (a unit's Management tab). */
19
+ unit?: string | null;
20
+ unitName?: string;
21
+ /**
22
+ * The person's user account. Anything acting on the PERSON needs this rather
23
+ * than `_id`, which identifies the membership: an access card carries it as
24
+ * `userId`, and HID reader access is bound by it -
25
+ * `resolvePermissionUserBindings` drops every subject without one.
26
+ *
27
+ * Returned from core 3.130. Before that the repository projected it and the
28
+ * service layer dropped it, so against an older API it is absent on every
29
+ * row - `providerAccountsKnown` is how the HID enrolment screen tells the two
30
+ * apart rather than reading an absence as "nobody has an account".
31
+ */
32
+ user?: string | null;
18
33
  };
19
34
 
20
35
  export type TSiteProviderCompany = {
@@ -90,6 +105,8 @@ export default function useServiceProvider() {
90
105
  status = "",
91
106
  /** "engagements": also providers engaged through an accepted invitation. */
92
107
  include = "",
108
+ /** A building unit id, or "none": providers on no unit yet. */
109
+ unit = "",
93
110
  } = {}) {
94
111
  return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
95
112
  method: "GET",
@@ -102,6 +119,7 @@ export default function useServiceProvider() {
102
119
  siteId,
103
120
  ...(status ? { status } : {}),
104
121
  ...(include ? { include } : {}),
122
+ ...(unit ? { unit } : {}),
105
123
  },
106
124
  });
107
125
  }
@@ -269,6 +287,17 @@ export default function useServiceProvider() {
269
287
  );
270
288
  }
271
289
 
290
+ /** Attach a provider to a building unit, or detach it (`unit` ""). */
291
+ async function updateUnit(id: string, unit: string) {
292
+ return useNuxtApp().$api<Record<string, any>>(
293
+ `/api/service-providers/${id}/unit`,
294
+ {
295
+ method: "PATCH",
296
+ body: { unit },
297
+ }
298
+ );
299
+ }
300
+
272
301
  async function getByEmail({
273
302
  email = "",
274
303
  orgId = "",
@@ -293,17 +322,29 @@ export default function useServiceProvider() {
293
322
  * Members > Service Providers: the provider people with access to this
294
323
  * site, and one entry per provider company with its head count. The
295
324
  * site's own organisation only - the server refuses anyone else.
325
+ * `unit`: a building unit id, or "none" (people on no unit yet).
296
326
  */
297
- function getSiteMembers(siteId: string): Promise<{
327
+ function getSiteMembers(siteId: string, unit = ""): Promise<{
298
328
  items: TSiteProviderMember[];
299
329
  companies: TSiteProviderCompany[];
300
330
  }> {
301
331
  return useNuxtApp().$api("/api/service-providers/site-members", {
302
332
  method: "GET",
303
- query: { siteId },
333
+ query: { siteId, ...(unit ? { unit } : {}) },
304
334
  });
305
335
  }
306
336
 
337
+ /** Attach one of those people to a building unit, or detach them (`unit` ""). */
338
+ function updateSiteMemberUnit(id: string, unit: string) {
339
+ return useNuxtApp().$api<Record<string, any>>(
340
+ `/api/service-providers/site-members/${id}/unit`,
341
+ {
342
+ method: "PATCH",
343
+ body: { unit },
344
+ }
345
+ );
346
+ }
347
+
307
348
  /** The same list as an Excel file, under the same filters. */
308
349
  function exportSiteMembers(
309
350
  siteId: string,
@@ -320,6 +361,7 @@ export default function useServiceProvider() {
320
361
 
321
362
  return {
322
363
  getSiteMembers,
364
+ updateSiteMemberUnit,
323
365
  exportSiteMembers,
324
366
  serviceProviders,
325
367
  serviceProvider,
@@ -338,6 +380,7 @@ export default function useServiceProvider() {
338
380
  add,
339
381
  addViaInvite,
340
382
  updateStatus,
383
+ updateUnit,
341
384
  getByEmail,
342
385
  };
343
386
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * THE CATEGORY OF THE SITE THE USER IS CURRENTLY IN.
3
+ *
4
+ * One shared answer, published once by the application's layout from the site
5
+ * it already loaded for the switcher, and read by anything that has to behave
6
+ * differently on a commercial or industrial site - the business Add Tenant
7
+ * form, the tenant list. Publishing it rather than re-fetching it per
8
+ * component means no two screens can disagree about which site this is.
9
+ *
10
+ * READ FROM THE CUSTOMER-SITE RECORD, NOT THE SITE RECORD. Both carry a
11
+ * `category` and `customer-site.service` keeps them equal (it writes the site
12
+ * on create and on update), but `siteSchema` DEFAULTS the site's own copy to
13
+ * `commercial` - so a site created without an explicit category reads back as
14
+ * commercial there even when it is a residential estate. The customer-site
15
+ * copy has no default: it is either the category somebody chose or nothing.
16
+ *
17
+ * An empty category means "not published yet" or "never set", and every
18
+ * caller must behave as it did before this existed - never assume commercial
19
+ * from silence.
20
+ */
21
+ const BUSINESS_SITE_CATEGORIES: string[] = ["commercial", "industrial"];
22
+
23
+ export default function useSiteCategory() {
24
+ const siteCategory = useState<string>("current-site-category", () => "");
25
+
26
+ function setSiteCategory(value?: string | null) {
27
+ siteCategory.value = typeof value === "string" ? value : "";
28
+ }
29
+
30
+ /**
31
+ * The categories whose units are LET TO A BUSINESS rather than lived in.
32
+ *
33
+ * These are the sites where a unit has an owner, an occupier and often a
34
+ * person in charge who is neither, so they are the sites that ask for a
35
+ * tenant's standing and print it back (see `OCCUPANCY_ROLE_OPTIONS`).
36
+ *
37
+ * The category never changes what the APPLICATION is called: the rail says
38
+ * Property Management on every site it serves.
39
+ */
40
+ const isBusinessSite = computed(() =>
41
+ BUSINESS_SITE_CATEGORIES.includes(siteCategory.value),
42
+ );
43
+
44
+ return { siteCategory, isBusinessSite, setSiteCategory };
45
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.90.1",
5
+ "version": "4.90.2-staging.484",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -5,7 +5,7 @@
5
5
  :org="orgId"
6
6
  message="Enable HID as a service for this site before managing HID users."
7
7
  >
8
- <HidUserEnrollment :site="siteId" />
8
+ <HidUserEnrollment :site="siteId" :org="orgId" />
9
9
  </HidEnabledGate>
10
10
  </v-container>
11
11
  </template>