@7365admin1/layer-common 4.82.0 → 4.82.1-staging.470

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 (53) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/assets/css/primitives.css +57 -0
  3. package/assets/css/screens.css +8 -4
  4. package/components/AccessCardDetailsDialog.vue +57 -4
  5. package/components/AccessCardPreviewDialog.vue +291 -50
  6. package/components/AppSelect.vue +143 -4
  7. package/components/BuildingUnitFormEdit.vue +6 -0
  8. package/components/BuildingUnitManagement.vue +298 -0
  9. package/components/Dialog/UpdateMoreAction.vue +11 -1
  10. package/components/DocumentForm.vue +407 -112
  11. package/components/DocumentManagement.vue +213 -12
  12. package/components/Facility/BookingSetup.vue +63 -0
  13. package/components/HidAccessLogDashboard.vue +74 -17
  14. package/components/HidAccessPermissions.vue +424 -0
  15. package/components/HidIntercomManagement.vue +183 -14
  16. package/components/HidProfileQrCode.vue +332 -0
  17. package/components/HidQrCodeConfiguration.vue +17 -195
  18. package/components/HidReaderManagement.vue +398 -0
  19. package/components/HidReaderUserRoster.vue +44 -3
  20. package/components/HidUserEnrollment.vue +1521 -248
  21. package/components/InvitationClientForm.vue +19 -1
  22. package/components/Layout/Header.vue +2 -0
  23. package/components/StaffViewBanner.vue +67 -0
  24. package/components/TableMain.vue +22 -7
  25. package/components/VisitorForm.vue +12 -0
  26. package/components/VisitorManagement.vue +267 -5
  27. package/composables/useDocument.ts +7 -0
  28. package/composables/useFacility.ts +11 -0
  29. package/composables/useHidAmico.ts +165 -0
  30. package/composables/useHidNavigation.ts +25 -1
  31. package/composables/useHidReaderSelection.ts +50 -0
  32. package/composables/useMember.ts +12 -0
  33. package/composables/usePeople.ts +19 -0
  34. package/composables/useServiceProvider.ts +40 -2
  35. package/composables/useSiteCategory.ts +45 -0
  36. package/composables/useStaffView.ts +49 -0
  37. package/package.json +1 -1
  38. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  39. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  40. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  41. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  42. package/plugins/secure-member.client.ts +31 -7
  43. package/types/document.d.ts +14 -0
  44. package/types/facility.d.ts +4 -0
  45. package/types/member.d.ts +4 -0
  46. package/types/people.d.ts +28 -1
  47. package/types/service-provider.d.ts +5 -0
  48. package/types/staff-view.d.ts +10 -0
  49. package/utils/hid-enrolment-subject.ts +144 -0
  50. package/utils/hid-permission-assignments.ts +190 -0
  51. package/utils/hid-reader-selection.ts +52 -0
  52. package/utils/occupancy-role.ts +109 -0
  53. package/utils/service-type.ts +30 -0
@@ -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,
@@ -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,16 @@ 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. NOT yet returned by the endpoint — the
23
+ * repository projects it but the service layer drops it. Anything acting on
24
+ * the PERSON (assigning an access card writes it onto the card as `userId`)
25
+ * needs this rather than `_id`, which identifies the membership.
26
+ */
27
+ user?: string | null;
18
28
  };
19
29
 
20
30
  export type TSiteProviderCompany = {
@@ -90,6 +100,8 @@ export default function useServiceProvider() {
90
100
  status = "",
91
101
  /** "engagements": also providers engaged through an accepted invitation. */
92
102
  include = "",
103
+ /** A building unit id, or "none": providers on no unit yet. */
104
+ unit = "",
93
105
  } = {}) {
94
106
  return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
95
107
  method: "GET",
@@ -102,6 +114,7 @@ export default function useServiceProvider() {
102
114
  siteId,
103
115
  ...(status ? { status } : {}),
104
116
  ...(include ? { include } : {}),
117
+ ...(unit ? { unit } : {}),
105
118
  },
106
119
  });
107
120
  }
@@ -269,6 +282,17 @@ export default function useServiceProvider() {
269
282
  );
270
283
  }
271
284
 
285
+ /** Attach a provider to a building unit, or detach it (`unit` ""). */
286
+ async function updateUnit(id: string, unit: string) {
287
+ return useNuxtApp().$api<Record<string, any>>(
288
+ `/api/service-providers/${id}/unit`,
289
+ {
290
+ method: "PATCH",
291
+ body: { unit },
292
+ }
293
+ );
294
+ }
295
+
272
296
  async function getByEmail({
273
297
  email = "",
274
298
  orgId = "",
@@ -293,17 +317,29 @@ export default function useServiceProvider() {
293
317
  * Members > Service Providers: the provider people with access to this
294
318
  * site, and one entry per provider company with its head count. The
295
319
  * site's own organisation only - the server refuses anyone else.
320
+ * `unit`: a building unit id, or "none" (people on no unit yet).
296
321
  */
297
- function getSiteMembers(siteId: string): Promise<{
322
+ function getSiteMembers(siteId: string, unit = ""): Promise<{
298
323
  items: TSiteProviderMember[];
299
324
  companies: TSiteProviderCompany[];
300
325
  }> {
301
326
  return useNuxtApp().$api("/api/service-providers/site-members", {
302
327
  method: "GET",
303
- query: { siteId },
328
+ query: { siteId, ...(unit ? { unit } : {}) },
304
329
  });
305
330
  }
306
331
 
332
+ /** Attach one of those people to a building unit, or detach them (`unit` ""). */
333
+ function updateSiteMemberUnit(id: string, unit: string) {
334
+ return useNuxtApp().$api<Record<string, any>>(
335
+ `/api/service-providers/site-members/${id}/unit`,
336
+ {
337
+ method: "PATCH",
338
+ body: { unit },
339
+ }
340
+ );
341
+ }
342
+
307
343
  /** The same list as an Excel file, under the same filters. */
308
344
  function exportSiteMembers(
309
345
  siteId: string,
@@ -320,6 +356,7 @@ export default function useServiceProvider() {
320
356
 
321
357
  return {
322
358
  getSiteMembers,
359
+ updateSiteMemberUnit,
323
360
  exportSiteMembers,
324
361
  serviceProviders,
325
362
  serviceProvider,
@@ -338,6 +375,7 @@ export default function useServiceProvider() {
338
375
  add,
339
376
  addViaInvite,
340
377
  updateStatus,
378
+ updateUnit,
341
379
  getByEmail,
342
380
  };
343
381
  }
@@ -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
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * "OPEN AS SEVEN365 STAFF" (owner, 2026-10-01).
3
+ *
4
+ * The server holds the open view against the session (`staff-view:<sid>`), so
5
+ * this only READS it - nothing here can open one or widen anything. Read once
6
+ * per page load; Exit clears it on the server and here.
7
+ */
8
+ const BASE = "/api/users/staff-access";
9
+
10
+ /** What a staff member is given inside the client they opened: full setup, like the client's owner. */
11
+ export const STAFF_VIEW_ROLE = Object.freeze({
12
+ name: "Seven365 staff",
13
+ permissions: ["*"],
14
+ }) as unknown as TRole;
15
+
16
+ /** Does the open view cover this route's organisation? */
17
+ export function staffViewCovers(view: TStaffView | null | undefined, org: string): boolean {
18
+ return !!view?.org && !!org && view.org === org;
19
+ }
20
+
21
+ export default function useStaffView() {
22
+ const staffView = useState<TStaffView | null>("staff-view", () => null);
23
+ const staffViewLoaded = useState<boolean>("staff-view-loaded", () => false);
24
+
25
+ async function loadStaffView(force = false): Promise<TStaffView | null> {
26
+ if (staffViewLoaded.value && !force) return staffView.value;
27
+ try {
28
+ const res = await useNuxtApp().$api<{ view?: TStaffView | null }>(`${BASE}/view`, {
29
+ method: "GET",
30
+ timeout: 5000,
31
+ });
32
+ staffView.value = res?.view ?? null;
33
+ } catch {
34
+ // No view is the safe answer: staff simply see what they saw before.
35
+ staffView.value = null;
36
+ }
37
+ staffViewLoaded.value = true;
38
+ return staffView.value;
39
+ }
40
+
41
+ async function exitStaffView(): Promise<string> {
42
+ const org = staffView.value?.org ?? "";
43
+ await useNuxtApp().$api(`${BASE}/view/exit`, { method: "POST" });
44
+ staffView.value = null;
45
+ return org;
46
+ }
47
+
48
+ return { staffView, staffViewLoaded, loadStaffView, exitStaffView };
49
+ }
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.82.0",
5
+ "version": "4.82.1-staging.470",
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>
@@ -5,7 +5,7 @@
5
5
  :org="orgId"
6
6
  message="Enable HID as a service for this site before managing physical HID cards."
7
7
  >
8
- <HidUserEnrollment :site="siteId" card-management />
8
+ <HidUserEnrollment :site="siteId" :org="orgId" card-management />
9
9
  </HidEnabledGate>
10
10
  </v-container>
11
11
  </template>
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <v-container fluid>
3
+ <HidEnabledGate
4
+ :site="siteId"
5
+ :org="orgId"
6
+ message="Enable HID as a service for this site before generating a QR code."
7
+ >
8
+ <HidProfileQrCode :site="siteId" />
9
+ </HidEnabledGate>
10
+ </v-container>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ definePageMeta({
15
+ layout: "default",
16
+ middleware: ["01-auth", "02-org"],
17
+ memberOnly: true,
18
+ });
19
+
20
+ const route = useRoute();
21
+ const siteId = computed(() => String(route.params.site ?? ""));
22
+ const orgId = computed(() => String(route.params.org ?? ""));
23
+ </script>
@@ -5,7 +5,7 @@
5
5
  :org="orgId"
6
6
  message="Enable HID as a service for this site before managing HID readers."
7
7
  >
8
- <HidReaderManagement :site="siteId" />
8
+ <HidReaderManagement :site="siteId" :org="orgId" />
9
9
  </HidEnabledGate>
10
10
  </v-container>
11
11
  </template>