@7365admin1/layer-common 4.72.0 → 4.73.1-staging.452

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 (54) hide show
  1. package/CHANGELOG.md +10 -4
  2. package/assets/css/primitives.css +43 -0
  3. package/components/AccessCardPreviewDialog.vue +286 -50
  4. package/components/AppSelect.vue +77 -3
  5. package/components/BuildingUnitFormEdit.vue +6 -0
  6. package/components/BuildingUnitManagement.vue +298 -0
  7. package/components/Dialog/UpdateMoreAction.vue +11 -1
  8. package/components/DocumentForm.vue +407 -112
  9. package/components/DocumentManagement.vue +213 -12
  10. package/components/Facility/BookingSetup.vue +63 -0
  11. package/components/HidAccessLogDashboard.vue +74 -17
  12. package/components/HidAccessPermissions.vue +424 -0
  13. package/components/HidIntercomManagement.vue +183 -14
  14. package/components/HidProfileQrCode.vue +332 -0
  15. package/components/HidQrCodeConfiguration.vue +17 -195
  16. package/components/HidReaderManagement.vue +398 -0
  17. package/components/HidReaderUserRoster.vue +44 -3
  18. package/components/HidUserEnrollment.vue +845 -155
  19. package/components/InventoryHistoryDialog.vue +205 -0
  20. package/components/InventoryMain.vue +23 -2
  21. package/components/InventoryMyStockTab.vue +63 -8
  22. package/components/InventoryPhotoThumbs.vue +67 -0
  23. package/components/InventoryReportsTab.vue +154 -28
  24. package/components/InventoryUsageDialog.vue +119 -28
  25. package/components/InvitationClientForm.vue +19 -1
  26. package/components/VisitorForm.vue +12 -0
  27. package/components/VisitorManagement.vue +267 -5
  28. package/composables/useDocument.ts +7 -0
  29. package/composables/useFacility.ts +11 -0
  30. package/composables/useHidAmico.ts +165 -0
  31. package/composables/useHidNavigation.ts +25 -1
  32. package/composables/useHidReaderSelection.ts +50 -0
  33. package/composables/useInventory.ts +11 -3
  34. package/composables/useMember.ts +12 -0
  35. package/composables/usePeople.ts +19 -0
  36. package/composables/useSecurityPermission.ts +20 -0
  37. package/composables/useServiceProvider.ts +33 -2
  38. package/composables/useSiteCategory.ts +45 -0
  39. package/package.json +1 -1
  40. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  41. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  42. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  43. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  44. package/types/document.d.ts +14 -0
  45. package/types/facility.d.ts +4 -0
  46. package/types/inventory.d.ts +18 -2
  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/utils/hid-permission-assignments.ts +190 -0
  51. package/utils/hid-reader-selection.ts +52 -0
  52. package/utils/inventory-usage.ts +94 -0
  53. package/utils/occupancy-role.ts +109 -0
  54. package/utils/service-type.ts +30 -0
@@ -749,11 +749,35 @@
749
749
  class="visitor-preview__row"
750
750
  >
751
751
  <div class="visitor-preview__label">{{ label }}</div>
752
- <div
753
- v-tooltip:top="selectedVisitorObject[key]"
754
- class="visitor-preview__value"
755
- >
756
- {{ maskNRIC(selectedVisitorObject[key]) }}
752
+ <div>
753
+ <!-- Was a hover tooltip on the value: the full NRIC only
754
+ reachable by hovering, which says nothing is there to
755
+ reach and cannot be reached at all on a touch screen.
756
+ The eye alone, at the 14px the Incident Report screens
757
+ draw it, is a 14px target - the floor is 24px. So the
758
+ NUMBER is the control and the eye is its affordance:
759
+ the whole masked value is pressable, which makes the
760
+ target the width of the digits rather than of a glyph,
761
+ and being a real `button` it also takes a tab stop,
762
+ which a `v-icon` with a click handler never did. -->
763
+ <button
764
+ type="button"
765
+ class="visitor-preview__reveal"
766
+ :aria-label="showVisitorNric ? 'Hide NRIC' : 'Show NRIC'"
767
+ :aria-pressed="showVisitorNric"
768
+ @click="showVisitorNric = !showVisitorNric"
769
+ >
770
+ <span class="visitor-preview__value">
771
+ {{
772
+ showVisitorNric
773
+ ? selectedVisitorObject[key]
774
+ : maskNRIC(selectedVisitorObject[key])
775
+ }}
776
+ </span>
777
+ <v-icon size="16" class="visitor-preview__eye">
778
+ {{ showVisitorNric ? "mdi-eye-off-outline" : "mdi-eye-outline" }}
779
+ </v-icon>
780
+ </button>
757
781
  </div>
758
782
  </div>
759
783
 
@@ -803,6 +827,84 @@
803
827
  </div>
804
828
  </div>
805
829
 
830
+ <!--
831
+ THE CONTRACTOR'S PARTY.
832
+
833
+ The list row has always said `( +2 members)` beside the name
834
+ and then had nowhere to send you for the names themselves. The
835
+ block spans both columns rather than sitting in the 116px
836
+ value track: a member is a record, not a value, and several of
837
+ them in a 250px column is unreadable.
838
+
839
+ Read off `selectedVisitorDataObject` (the raw row) and not
840
+ `selectedVisitorObject`, which filters itself down to
841
+ `typeFieldMap` plus five fixed keys - `members` is on neither
842
+ list, and widening that computed would change what four other
843
+ dialogs on this screen see.
844
+ -->
845
+ <div
846
+ v-else-if="key === 'members' && selectedVisitorMembers.length"
847
+ class="visitor-preview__row visitor-preview__row--block"
848
+ >
849
+ <div class="visitor-preview__label">
850
+ {{ label }} ({{ selectedVisitorMembers.length }})
851
+ </div>
852
+ <div class="visitor-preview__members">
853
+ <div
854
+ v-for="(member, index) in selectedVisitorMembers"
855
+ :key="member?.nric || member?.name || index"
856
+ class="visitor-preview__member"
857
+ >
858
+ <div class="visitor-preview__value">
859
+ {{ member?.name || "N/A" }}
860
+ </div>
861
+ <template v-for="field in memberDetailFields" :key="field.key">
862
+ <div
863
+ v-if="member?.[field.key]"
864
+ class="visitor-preview__member-line"
865
+ >
866
+ <span class="visitor-preview__member-key">
867
+ {{ field.label }}
868
+ </span>
869
+ <!-- A member's NRIC is the same class of data as the
870
+ visitor's, so it gets the same control. Each
871
+ member reveals separately - one toggle for the
872
+ whole card would show three people's NRICs to
873
+ read one. -->
874
+ <button
875
+ v-if="field.key === 'nric'"
876
+ type="button"
877
+ class="visitor-preview__reveal"
878
+ :aria-label="
879
+ isMemberNricShown(index)
880
+ ? `Hide NRIC for ${member?.name || 'this member'}`
881
+ : `Show NRIC for ${member?.name || 'this member'}`
882
+ "
883
+ :aria-pressed="isMemberNricShown(index)"
884
+ @click="toggleMemberNric(index)"
885
+ >
886
+ <span>
887
+ {{
888
+ isMemberNricShown(index)
889
+ ? member.nric
890
+ : maskNRIC(member.nric)
891
+ }}
892
+ </span>
893
+ <v-icon size="16" class="visitor-preview__eye">
894
+ {{
895
+ isMemberNricShown(index)
896
+ ? "mdi-eye-off-outline"
897
+ : "mdi-eye-outline"
898
+ }}
899
+ </v-icon>
900
+ </button>
901
+ <span v-else>{{ member[field.key] }}</span>
902
+ </div>
903
+ </template>
904
+ </div>
905
+ </div>
906
+ </div>
907
+
806
908
  <!-- The vehicle number, with Block on its right: the Registered
807
909
  tab only, for someone who may add vehicles. It opens the
808
910
  Vehicle Mgmt Block Listed form with the category taken from
@@ -2123,6 +2225,71 @@ const isSelectedVisitorPendingApproval = computed(
2123
2225
  () => selectedVisitorStatus.value === "pending"
2124
2226
  );
2125
2227
 
2228
+ /**
2229
+ * The members a contractor brought with them. Not gated on the Guests tab: the
2230
+ * list row's own `( +N members)` count is not either, and a contractor with a
2231
+ * party has one wherever the screen shows it.
2232
+ *
2233
+ * Blank entries are dropped rather than drawn as an empty card - the payload
2234
+ * carries `""` for every detail nobody filled in, so a member with no name and
2235
+ * no details would otherwise render as a bare inset box.
2236
+ */
2237
+ const selectedVisitorMembers = computed<Record<string, any>[]>(() => {
2238
+ const members = selectedVisitorDataObject.value?.members;
2239
+ if (!Array.isArray(members)) return [];
2240
+
2241
+ return members.filter(
2242
+ (member: Record<string, any>) =>
2243
+ member?.name || member?.nric || member?.contact || member?.plateNumber
2244
+ );
2245
+ });
2246
+
2247
+ /**
2248
+ * WHICH NRICs ARE UNCOVERED RIGHT NOW.
2249
+ *
2250
+ * Per member and not per card, so revealing one person's number does not
2251
+ * uncover the rest of the party's. Both are cleared when the dialog closes -
2252
+ * a preview must not open on the next visitor with the last one's NRIC
2253
+ * already showing, and it is the same `selectedVisitorId` that would carry it
2254
+ * across if the same row were reopened.
2255
+ */
2256
+ const showVisitorNric = ref(false);
2257
+ const shownMemberNrics = ref<number[]>([]);
2258
+
2259
+ function isMemberNricShown(index: number) {
2260
+ return shownMemberNrics.value.includes(index);
2261
+ }
2262
+
2263
+ function toggleMemberNric(index: number) {
2264
+ shownMemberNrics.value = isMemberNricShown(index)
2265
+ ? shownMemberNrics.value.filter((x) => x !== index)
2266
+ : [...shownMemberNrics.value, index];
2267
+ }
2268
+
2269
+ watch(
2270
+ () => dialog.viewVisitor,
2271
+ (open) => {
2272
+ if (open) return;
2273
+ showVisitorNric.value = false;
2274
+ shownMemberNrics.value = [];
2275
+ }
2276
+ );
2277
+
2278
+ /**
2279
+ * What a member row prints under the name, in order. `plateNumber` is in here
2280
+ * because the API returns it on `members[]` even though neither
2281
+ * `TMemberInfo` (this package) nor `TContractorMembers` (API-core's visitor
2282
+ * model, name and nric only) declares it - the two types have drifted from the
2283
+ * document and from each other. Reading the key defensively costs nothing and
2284
+ * shows the vehicle a member actually arrived in; the types are somebody's to
2285
+ * reconcile separately.
2286
+ */
2287
+ const memberDetailFields = [
2288
+ { key: "nric", label: "NRIC" },
2289
+ { key: "contact", label: "Contact" },
2290
+ { key: "plateNumber", label: "Vehicle" },
2291
+ ] as const;
2292
+
2126
2293
  const formatType = (item: any) =>
2127
2294
  (item.deliveryType ? item.deliveryType + "-" : "") + item.type;
2128
2295
 
@@ -2136,6 +2303,7 @@ const formattedFields = {
2136
2303
  level: "Level",
2137
2304
  unit: "Unit",
2138
2305
  purpose: "Purpose",
2306
+ members: "Members",
2139
2307
  checkIn: "Check In",
2140
2308
  snapshotEntryImage: "Entry Image",
2141
2309
  checkOut: "Check Out",
@@ -3142,6 +3310,100 @@ watchEffect(async () => {
3142
3310
  word-break: break-word;
3143
3311
  }
3144
3312
 
3313
+ /* A row whose value is a set of records rather than a value - it drops the
3314
+ two-column grid and runs the full width of the card body. */
3315
+ .visitor-preview__row--block {
3316
+ display: block;
3317
+ }
3318
+
3319
+ .visitor-preview__members {
3320
+ display: flex;
3321
+ flex-direction: column;
3322
+ gap: 8px;
3323
+ margin-top: 8px;
3324
+ }
3325
+
3326
+ /*
3327
+ * An added member reads as an inset on the card it sits in - `--hover` on
3328
+ * `--border` at the inner radius. Those are `Card/MemberInfoSummary`'s three
3329
+ * decisions, unchanged, so a member looks the same in the preview as it does
3330
+ * in the form that created it. Only the TYPE differs: that card still prints
3331
+ * `<strong>Label:</strong> value`, which is the pattern this dialog just moved
3332
+ * off, so the lines below are set on the scale rather than inherited.
3333
+ */
3334
+ .visitor-preview__member {
3335
+ padding: 9px 12px;
3336
+ border: 1px solid var(--border);
3337
+ border-radius: var(--r-inner);
3338
+ background: var(--hover);
3339
+ }
3340
+
3341
+ .visitor-preview__member-line {
3342
+ display: flex;
3343
+ gap: 8px;
3344
+ margin-top: 3px;
3345
+ font-size: var(--fs-breadcrumb);
3346
+ color: var(--text2);
3347
+ word-break: break-word;
3348
+ }
3349
+
3350
+ .visitor-preview__member-key {
3351
+ flex: 0 0 52px;
3352
+ color: var(--muted);
3353
+ }
3354
+
3355
+ /*
3356
+ * THE NRIC REVEAL.
3357
+ *
3358
+ * The pressable thing is the masked number, not the glyph beside it: an eye on
3359
+ * its own is a 14-16px target where 24px is the floor, and on a 12.5px member
3360
+ * line an `AppButton variant="icon"` - the layer's 32px icon square - would
3361
+ * make the NRIC line half again the height of the Contact line under it.
3362
+ * Pressing the digits gives a target the width of the value at no cost to the
3363
+ * rhythm, and reads the right way round: the number is what changes.
3364
+ *
3365
+ * It inherits its type rather than setting any, so the visitor's NRIC stays on
3366
+ * `--fs-cell` and a member's on the `--fs-breadcrumb` of the line it sits in.
3367
+ * The negative margin pays back the padding, so a revealed value starts on the
3368
+ * same left edge as every other value in the card.
3369
+ */
3370
+ .visitor-preview__reveal {
3371
+ display: inline-flex;
3372
+ align-items: center;
3373
+ gap: 6px;
3374
+ margin: -3px -7px;
3375
+ padding: 3px 7px;
3376
+ border: none;
3377
+ border-radius: var(--r-inner-sm);
3378
+ background: transparent;
3379
+ font: inherit;
3380
+ color: inherit;
3381
+ text-align: left;
3382
+ cursor: pointer;
3383
+ transition: background var(--motion) ease;
3384
+ }
3385
+
3386
+ .visitor-preview__reveal:hover {
3387
+ background: var(--hover);
3388
+ }
3389
+
3390
+ .visitor-preview__reveal:focus-visible {
3391
+ outline: 2px solid var(--accent);
3392
+ outline-offset: 1px;
3393
+ }
3394
+
3395
+ /* The design's interactive ink - not Vuetify's fixed blue, which is one colour
3396
+ on both themes. `affectedEntities` gives its NRIC eye the same value. */
3397
+ .visitor-preview__eye {
3398
+ color: var(--accent-text);
3399
+ }
3400
+
3401
+ @media (prefers-reduced-motion: reduce) {
3402
+ .visitor-preview__reveal {
3403
+ transition: none;
3404
+ }
3405
+ }
3406
+
3145
3407
  /* The width the type filter carried as `max-width="200"` on the v-select. */
3146
3408
  .visitor-type-filter {
3147
3409
  max-width: 200px;
@@ -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
+ }