@7365admin1/layer-common 4.97.1-staging.560 → 4.97.1-staging.562

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.
@@ -129,7 +129,11 @@
129
129
  </span>
130
130
  <v-spacer />
131
131
  <AppButton variant="ghost" :disabled="saving" @click="open = false">Cancel</AppButton>
132
+ <!-- Reachable only from a menu item the users right draws; the same
133
+ right is asked again here so the dialog stays read only if it is
134
+ ever opened some other way. -->
132
135
  <AppButton
136
+ v-if="canManageHidUsers"
133
137
  icon="mdi-content-save-outline"
134
138
  :loading="saving"
135
139
  :disabled="!readerLocation || !dirty || saving"
@@ -185,6 +189,8 @@ const props = defineProps<{
185
189
  reader: Record<string, unknown> | null;
186
190
  }>();
187
191
 
192
+ const { canManageHidUsers } = useHidAccessPermission();
193
+
188
194
  const emit = defineEmits<{
189
195
  (event: "update:modelValue", value: boolean): void;
190
196
  (event: "saved"): void;
@@ -22,16 +22,14 @@
22
22
  denial here would flash "no permission" at the owner on every load. -->
23
23
  <template v-if="!isAppRoleResolved" />
24
24
 
25
- <slot v-else-if="hidEnabled && canAccessHidScreens" />
25
+ <slot v-else-if="hidEnabled && permitted" />
26
26
 
27
27
  <div v-else-if="hidEnabled" class="screen-empty hid-gate">
28
28
  <span class="hid-gate__icon tone-info">
29
29
  <v-icon icon="mdi-lock-outline" size="24" />
30
30
  </span>
31
- <h2 class="hid-gate__title">You do not have permission for HID access management</h2>
32
- <p class="hid-gate__body">
33
- Ask an administrator to grant your role access card management for this site.
34
- </p>
31
+ <h2 class="hid-gate__title">{{ deniedTitle }}</h2>
32
+ <p class="hid-gate__body">{{ deniedBody }}</p>
35
33
  </div>
36
34
 
37
35
  <div v-else class="screen-empty hid-gate">
@@ -50,10 +48,18 @@ const props = withDefaults(
50
48
  org: string;
51
49
  message?: string;
52
50
  redirectToSettings?: boolean;
51
+ /**
52
+ * Which HID right opens the screen behind this gate. `view` is the admin
53
+ * screens (readers, users, cards, intercom, access logs: `canViewHid`);
54
+ * `use` is the member's own HID QR Code page (`canUseHid`). Defaults to the
55
+ * stricter one, so a page that forgets to say is an admin page.
56
+ */
57
+ level?: "view" | "use";
53
58
  }>(),
54
59
  {
55
60
  message: "Enable HID as a service for this site before accessing this screen.",
56
61
  redirectToSettings: true,
62
+ level: "view",
57
63
  },
58
64
  );
59
65
 
@@ -61,13 +67,26 @@ const { getSiteById } = useSiteSettings();
61
67
  const { getHidServiceEnabled } = useOptionalServices();
62
68
 
63
69
  // The permission half of the same gate. This component is the only thing all
64
- // six `access-mgmt` pages have in common, so putting the check here governs all
65
- // six -- and all 66 inherited routes across the eleven apps -- without a page
66
- // guard per screen. See `composables/useHidAccessPermission.ts` for why the
67
- // gate cannot remove access that currently works.
68
- const { canAccessHidScreens } = useHidAccessPermission();
70
+ // seven `access-mgmt` HID pages have in common, so putting the check here
71
+ // governs all of them, and every inherited route across the eleven apps,
72
+ // without a page guard per screen. See `composables/useHidAccessPermission.ts`
73
+ // for the five flags and the alias period.
74
+ const { canViewHid, canUseHid } = useHidAccessPermission();
69
75
  const { isAppRoleResolved } = useLocalSetup();
70
76
 
77
+ const permitted = computed(() => (props.level === "use" ? canUseHid.value : canViewHid.value));
78
+
79
+ const deniedTitle = computed(() =>
80
+ props.level === "use"
81
+ ? "You do not have permission for HID access"
82
+ : "You do not have permission for HID access management",
83
+ );
84
+ const deniedBody = computed(() =>
85
+ props.level === "use"
86
+ ? "Ask an administrator to grant your role HID access for this site."
87
+ : "Ask an administrator to grant your role HID management for this site.",
88
+ );
89
+
71
90
  // Do not await this request during route setup. Every HID page uses this gate;
72
91
  // awaiting it makes Nuxt Suspense keep rendering the previous page until the
73
92
  // site request finishes, so the URL changes while the visible module appears
@@ -46,16 +46,18 @@
46
46
  @update:page="page = $event"
47
47
  >
48
48
  <!-- The action swaps with the tab, as it did in the old top bar. -->
49
+ <!-- Contacts are reader objects, so adding one is the readers right.
50
+ The web call is a member level call and stays for everyone. -->
49
51
  <template #actions>
50
52
  <AppButton
51
- v-if="activeTab === 'contacts'"
53
+ v-if="activeTab === 'contacts' && canManageHidReaders"
52
54
  icon="mdi-plus"
53
55
  @click="openContactDialog()"
54
56
  >
55
57
  Add Contacts
56
58
  </AppButton>
57
59
  <AppButton
58
- v-else
60
+ v-else-if="activeTab !== 'contacts'"
59
61
  icon="mdi-phone-in-talk-outline"
60
62
  class="web-call-button"
61
63
  :class="webPhoneButtonClass"
@@ -151,23 +153,30 @@
151
153
  <template #activator="{ props: menuProps }">
152
154
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
153
155
  </template>
156
+ <!-- The reader's SIP settings, call settings, dial code and contacts
157
+ are reader configuration: the readers right. View and the status
158
+ check stay for the view right. -->
154
159
  <v-list v-if="activeTab === 'intercom'" density="compact" class="screen-menu">
155
160
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openViewDialog(item)" />
156
- <v-list-item
157
- class="screen-menu__item"
158
- title="Test Connection with SIP"
159
- prepend-icon="mdi-lan-check"
160
- :disabled="testingSipReaderId === item.reader._id"
161
- @click="testSipConnection(item)"
162
- />
163
- <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
164
- <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
161
+ <template v-if="canManageHidReaders">
162
+ <v-list-item
163
+ class="screen-menu__item"
164
+ title="Test Connection with SIP"
165
+ prepend-icon="mdi-lan-check"
166
+ :disabled="testingSipReaderId === item.reader._id"
167
+ @click="testSipConnection(item)"
168
+ />
169
+ <v-list-item class="screen-menu__item" title="Call Settings" prepend-icon="mdi-cog" @click="openCallDialog(item)" />
170
+ <v-list-item class="screen-menu__item" title="Dial Code" prepend-icon="mdi-dialpad" @click="openDialCodeDialog(item)" />
171
+ </template>
165
172
  </v-list>
166
173
  <v-list v-else density="compact" class="screen-menu">
167
174
  <v-list-item class="screen-menu__item" title="Check reader SIP status" prepend-icon="mdi-lan-check" @click="testContactSipStatus(item)" />
168
175
  <v-list-item class="screen-menu__item" title="View" prepend-icon="mdi-eye" @click="openContactView(item)" />
169
- <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
170
- <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
176
+ <template v-if="canManageHidReaders">
177
+ <v-list-item class="screen-menu__item" title="Edit" prepend-icon="mdi-pencil" @click="openContactDialog(item)" />
178
+ <v-list-item class="screen-menu__item screen-menu__item--danger" title="Delete" prepend-icon="mdi-delete-outline" @click="openDeleteContact(item)" />
179
+ </template>
171
180
  </v-list>
172
181
  </v-menu>
173
182
  </template>
@@ -749,6 +758,10 @@ type IntercomRow = {
749
758
  pjsip: Record<string, unknown>;
750
759
  };
751
760
 
761
+ // Reader configuration (SIP, call settings, dial code, contacts) is the readers
762
+ // right. The screen itself is behind `HidEnabledGate` (the view right).
763
+ const { canManageHidReaders } = useHidAccessPermission();
764
+
752
765
  const {
753
766
  getReaders,
754
767
  getReaderConfiguration,
@@ -121,7 +121,7 @@ import type { HidProfileQr } from "../composables/useHidAmico";
121
121
 
122
122
  const props = defineProps<{ site: string }>();
123
123
 
124
- const { getReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
124
+ const { getEnrollmentReaders, getProfileQr, issueProfileQr, deleteProfileQr } = useHidAmico();
125
125
 
126
126
  type HidReaderOption = { _id: string; name?: string; portalName?: string };
127
127
 
@@ -200,7 +200,11 @@ function downloadQr() {
200
200
 
201
201
  async function loadReaders() {
202
202
  if (!props.site) return;
203
- const response = toRecord(await getReaders({ site: props.site, page: 1, limit: 100 }));
203
+ /* The self service list, not the admin one. `GET /readers` sits behind the
204
+ HID view right, so a member holding only `hid-mgmt:use-hid-access` (the
205
+ right this page is drawn for) was refused before the picker could fill.
206
+ `enrollment-readers` is the same site's enabled readers, for members. */
207
+ const response = toRecord(await getEnrollmentReaders(props.site));
204
208
  const data = toRecord(response.data);
205
209
  const items = response.items ?? data.items ?? data.readers ?? [];
206
210
  readers.value = (Array.isArray(items) ? items : []).filter((reader) => reader?._id);
@@ -29,7 +29,10 @@
29
29
  show-header
30
30
  @refresh="loadReaders"
31
31
  >
32
- <template #actions>
32
+ <!-- Hidden, not disabled, for a member without the right: the server
33
+ refuses the call anyway, and a button that cannot work is noise.
34
+ `hid-mgmt:manage-hid-readers` (`useHidAccessPermission`). -->
35
+ <template v-if="canManageHidReaders" #actions>
33
36
  <AppButton icon="mdi-plus" @click="openAdd">Add HID Reader</AppButton>
34
37
  </template>
35
38
 
@@ -85,14 +88,23 @@
85
88
  <AppButton v-bind="menuProps" variant="row" icon="mdi-dots-vertical" />
86
89
  </template>
87
90
 
91
+ <!-- View is the view right. Access Permissions assigns people to the
92
+ reader's group, so it is the users right; everything else acts on
93
+ the reader itself and is the readers right. -->
88
94
  <v-list density="compact" min-width="180">
89
95
  <v-list-item title="View" @click="openView(item)" />
90
- <v-list-item title="Access Permissions" @click="openPermissions(item)" />
91
- <v-list-item title="Identification Methods" @click="openIdentification(item)" />
92
- <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
93
- <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
94
- <v-list-item title="Edit" @click="openEdit(item)" />
95
- <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
96
+ <v-list-item
97
+ v-if="canManageHidUsers"
98
+ title="Access Permissions"
99
+ @click="openPermissions(item)"
100
+ />
101
+ <template v-if="canManageHidReaders">
102
+ <v-list-item title="Identification Methods" @click="openIdentification(item)" />
103
+ <v-list-item title="Sync HID Reader" @click="openSyncConfirm(item)" />
104
+ <v-list-item title="Test Connection" @click="openTestConfirm(item)" />
105
+ <v-list-item title="Edit" @click="openEdit(item)" />
106
+ <v-list-item title="Delete" class="text-error" @click="openDeleteConfirm(item)" />
107
+ </template>
96
108
  </v-list>
97
109
  </v-menu>
98
110
  </template>
@@ -136,7 +148,7 @@
136
148
  <span>Username</span><strong>{{ selectedReader?.username || "N/A" }}</strong>
137
149
  </div>
138
150
 
139
- <div class="dialog-actions-inline">
151
+ <div v-if="canManageHidReaders" class="dialog-actions-inline">
140
152
  <AppButton variant="ghost" @click="openTestConfirm(selectedReader)">Test Connection</AppButton>
141
153
  <AppButton variant="ghost" @click="openSyncConfirm(selectedReader)">Sync Reader</AppButton>
142
154
  </div>
@@ -481,6 +493,10 @@ const props = defineProps({
481
493
  },
482
494
  });
483
495
 
496
+ // Which buttons this member gets. The screen itself is behind `HidEnabledGate`
497
+ // (the view right); these two decide the write actions on it.
498
+ const { canManageHidReaders, canManageHidUsers } = useHidAccessPermission();
499
+
484
500
  const {
485
501
  getReaders,
486
502
  createReader,
@@ -68,7 +68,8 @@
68
68
  </span>
69
69
  </template>
70
70
 
71
- <template #[`item.action-table`]="{ item }">
71
+ <!-- Setting a PIN is the users right; the roster itself is the view right. -->
72
+ <template v-if="canManageHidUsers" #[`item.action-table`]="{ item }">
72
73
  <AppButton
73
74
  variant="row"
74
75
  icon="mdi-form-textbox-password"
@@ -199,6 +200,7 @@ type HidReaderUser = Record<string, unknown> & {
199
200
  metadata?: HidMetadata;
200
201
  };
201
202
 
203
+ const { canManageHidUsers } = useHidAccessPermission();
202
204
  const {
203
205
  getReaders,
204
206
  getReaderUsers,
@@ -53,7 +53,9 @@
53
53
  @refresh="loadUsers"
54
54
  @update:page="goToPage"
55
55
  >
56
- <template v-if="!props.cardManagement" #actions>
56
+ <!-- Enrolling is the users right (`hid-mgmt:manage-hid-users`). Hidden,
57
+ not disabled: the server refuses the call for a member without it. -->
58
+ <template v-if="!props.cardManagement && canManageHidUsers" #actions>
57
59
  <AppButton icon="mdi-account-plus" @click="openEnroll"
58
60
  >Enroll</AppButton
59
61
  >
@@ -141,14 +143,14 @@
141
143
 
142
144
  <template #[`item.action-table`]="{ item }">
143
145
  <AppButton
144
- v-if="props.cardManagement"
146
+ v-if="props.cardManagement && canManageHidUsers"
145
147
  variant="secondary"
146
148
  icon="mdi-card-account-details-outline"
147
149
  @click="openCardManager(item)"
148
150
  >
149
151
  Manage
150
152
  </AppButton>
151
- <v-menu v-else>
153
+ <v-menu v-else-if="!props.cardManagement">
152
154
  <template #activator="{ props: menuProps }">
153
155
  <AppButton
154
156
  v-bind="menuProps"
@@ -159,16 +161,18 @@
159
161
 
160
162
  <v-list density="compact" min-width="150">
161
163
  <v-list-item title="View" @click="openView(item)" />
162
- <v-list-item title="Edit" @click="openEdit(item)" />
163
- <v-list-item
164
- title="Manage HID Cards"
165
- @click="openCardManager(item)"
166
- />
167
- <v-list-item
168
- title="Delete"
169
- class="text-error"
170
- @click="openDelete(item)"
171
- />
164
+ <template v-if="canManageHidUsers">
165
+ <v-list-item title="Edit" @click="openEdit(item)" />
166
+ <v-list-item
167
+ title="Manage HID Cards"
168
+ @click="openCardManager(item)"
169
+ />
170
+ <v-list-item
171
+ title="Delete"
172
+ class="text-error"
173
+ @click="openDelete(item)"
174
+ />
175
+ </template>
172
176
  </v-list>
173
177
  </v-menu>
174
178
  </template>
@@ -1261,6 +1265,10 @@ const props = defineProps({
1261
1265
  },
1262
1266
  });
1263
1267
 
1268
+ // Enrol, edit, delete, cards and PINs are all the users right. The screen
1269
+ // itself is behind `HidEnabledGate` (the view right).
1270
+ const { canManageHidUsers } = useHidAccessPermission();
1271
+
1264
1272
  const {
1265
1273
  getReaders,
1266
1274
  getIdentities,
@@ -186,7 +186,9 @@
186
186
  </v-expansion-panel-text>
187
187
  </v-expansion-panel>
188
188
 
189
- <v-expansion-panel>
189
+ <!-- HID on or off for the site and the HID QR configuration:
190
+ `hid-mgmt:manage-hid-settings` (`useHidAccessPermission`). -->
191
+ <v-expansion-panel v-if="canManageHidSettings">
190
192
  <v-expansion-panel-title>
191
193
  <v-icon class="mr-2">mdi-face-recognition</v-icon>
192
194
  HID Face Reader
@@ -230,6 +232,9 @@
230
232
  <v-expansion-panel-text>
231
233
  <SiteSettingsVisitorRegistration :site-id="siteId" :site-data="siteData"
232
234
  :can-manage="canManageSiteSettings" @saved="refreshSiteData" @message="show" />
235
+ <v-divider class="my-4" />
236
+ <VisitorPassSmsSettings :site-id="siteId" :saved="(siteData as any)?.metadata?.visitorPassSms"
237
+ :loaded="!!siteData" :read-only="!canManageSiteSettings" @saved="refreshSiteData" />
233
238
  </v-expansion-panel-text>
234
239
  </v-expansion-panel>
235
240
 
@@ -304,6 +309,7 @@ const { canManageSiteInformation,
304
309
  canManageVehicleQr,
305
310
  canManageSiteSettings: canManageAnySiteSetting,
306
311
  } = useSettingsPermission();
312
+ const { canManageHidSettings } = useHidAccessPermission();
307
313
 
308
314
  const { getSiteById, updateSitebyId, updateSiteInformation } =
309
315
  useSiteSettings();
@@ -673,7 +673,7 @@ const {
673
673
  const { getBySiteId: getEntryPassSettingsBySiteId } =
674
674
  useSiteEntryPassSettings();
675
675
  const { createVisitorPass, signQr, visitorCheckout } = useAccessManagement();
676
- const { getReaders, issueVisitorQr } = useHidAmico();
676
+ const { getEnrollmentReaders, issueVisitorQr } = useHidAmico();
677
677
  const { testConnection } = useWebUsb();
678
678
  const {
679
679
  findPersonByNRIC,
@@ -1561,8 +1561,14 @@ watch(
1561
1561
  hidQrReader.value = null;
1562
1562
  if (!site) return;
1563
1563
  try {
1564
- const response = await getReaders({ site, page: 1, limit: 100 });
1565
- const readers: unknown = response?.items ?? response?.data?.items ?? response?.data?.readers ?? [];
1564
+ /* The member's list, not the admin one. `POST /readers/:id/visitor-qr`
1565
+ asks for membership plus `hid-mgmt:use-hid-access` (API-core #1772),
1566
+ while `GET /readers` asks for the HID view right, so a member who may
1567
+ issue a visitor pass but holds no admin right got the pass route and
1568
+ not the reader it needs. `enrollment-readers` is the site's enabled
1569
+ readers with a portal, `{ data: { items } }`, for any member. */
1570
+ const response = await getEnrollmentReaders(site);
1571
+ const readers: unknown = response?.data?.items ?? [];
1566
1572
  const availableReaders = Array.isArray(readers)
1567
1573
  ? readers.filter((reader: unknown): reader is HidQrReaderSummary => (
1568
1574
  typeof reader === "object"
@@ -570,6 +570,24 @@
570
570
  </v-list-item>
571
571
  </v-card>
572
572
  </v-menu>
573
+ <!-- Walk-in pass by SMS: only when the site switched it on and this user may add visitors. -->
574
+ <v-menu
575
+ v-else-if="activeTab === 'guests' && item?.status === 'approved' && !item?.checkOut && canAddVisitor && passSmsEnabled"
576
+ >
577
+ <template #activator="{ props }">
578
+ <v-avatar v-bind="props" class="rounded-xl border-md" data-test="visitor-pass-sms-menu">
579
+ <v-icon icon="mdi-dots-vertical" />
580
+ </v-avatar>
581
+ </template>
582
+
583
+ <v-card>
584
+ <v-list-item data-test="visitor-pass-sms-open" @click.stop="openPassSms(item)">
585
+ <template #title>
586
+ <span class="text-caption">Send pass by SMS</span>
587
+ </template>
588
+ </v-list-item>
589
+ </v-card>
590
+ </v-menu>
573
591
  </template>
574
592
 
575
593
  <template v-slot:item.checkInRemarks="{ item }">
@@ -1560,6 +1578,35 @@
1560
1578
  </v-card>
1561
1579
  </v-dialog>
1562
1580
 
1581
+ <v-dialog v-model="passSms.open" max-width="420">
1582
+ <v-card data-test="visitor-pass-sms-dialog">
1583
+ <v-toolbar color="transparent" density="comfortable" class="px-2">
1584
+ <v-toolbar-title class="text-subtitle-1 font-weight-bold">Send pass by SMS</v-toolbar-title>
1585
+ <v-btn icon="mdi-close" variant="text" title="Close" @click="passSms.open = false" />
1586
+ </v-toolbar>
1587
+ <v-card-text>
1588
+ <p class="text-body-2 mb-3">
1589
+ {{ passSms.name }} gets a text with the site name, the visit date and their pass link.
1590
+ </p>
1591
+ <v-text-field v-model.trim="passSms.phone" label="Mobile number" placeholder="e.g. 9123 4567"
1592
+ density="comfortable" variant="outlined" maxlength="30" :disabled="passSms.sending"
1593
+ data-test="visitor-pass-sms-phone" @keyup.enter="sendPassSmsNow" />
1594
+ <p v-if="passSms.result" class="text-body-2 mt-1" :class="passSms.ok ? 'text-success' : 'text-error'"
1595
+ data-test="visitor-pass-sms-result">
1596
+ {{ passSms.result }}
1597
+ </p>
1598
+ </v-card-text>
1599
+ <v-card-actions class="px-6 pb-4">
1600
+ <v-spacer />
1601
+ <v-btn variant="text" @click="passSms.open = false">Close</v-btn>
1602
+ <v-btn class="screen-btn-primary" color="primary-button" variant="flat" :loading="passSms.sending"
1603
+ :disabled="!passSms.phone" data-test="visitor-pass-sms-send" @click="sendPassSmsNow">
1604
+ Send
1605
+ </v-btn>
1606
+ </v-card-actions>
1607
+ </v-card>
1608
+ </v-dialog>
1609
+
1563
1610
  <Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
1564
1611
  </v-row>
1565
1612
  </template>
@@ -1567,6 +1614,7 @@
1567
1614
  <script setup lang="ts">
1568
1615
  import moment from "moment-timezone";
1569
1616
  import QRCode from "qrcode";
1617
+ import { isVisitorPassSmsOn } from "../composables/useVisitor";
1570
1618
  import {
1571
1619
  VISITOR_SEARCH_DEBOUNCE_MS,
1572
1620
  visitorSearchEmptyText,
@@ -1637,6 +1685,7 @@ const {
1637
1685
  typeFieldMap,
1638
1686
  updateVisitor,
1639
1687
  visitorDataFromScannedQRCodeCheckIn,
1688
+ sendPassSms,
1640
1689
  } = useVisitor();
1641
1690
  const { visitorCheckout } = useAccessManagement();
1642
1691
  const {
@@ -1673,6 +1722,37 @@ const hidQrVisitor = ref<Record<string, any> | null>(null);
1673
1722
  const hidQrConfig = ref({ enabled: false, readerId: "", validityMinutes: 60 });
1674
1723
  let hidQrTimer: ReturnType<typeof setInterval> | null = null;
1675
1724
  const hidQrEnabled = computed(() => hidQrConfig.value.enabled && Boolean(hidQrConfig.value.readerId));
1725
+ // Walk-in pass by SMS: read with the HID settings (same site document).
1726
+ const passSmsEnabled = ref(false);
1727
+ const passSms = reactive({ open: false, id: "", name: "", phone: "", sending: false, result: "", ok: false });
1728
+
1729
+ function openPassSms(item: Record<string, any>) {
1730
+ Object.assign(passSms, {
1731
+ open: true,
1732
+ id: String(item?._id ?? ""),
1733
+ name: item?.name || "The visitor",
1734
+ phone: String(item?.contact ?? ""),
1735
+ sending: false,
1736
+ result: "",
1737
+ ok: false,
1738
+ });
1739
+ }
1740
+
1741
+ async function sendPassSmsNow() {
1742
+ if (!passSms.id || !passSms.phone || passSms.sending) return;
1743
+ passSms.sending = true;
1744
+ passSms.result = "";
1745
+ try {
1746
+ const res: any = await sendPassSms(passSms.id, passSms.phone);
1747
+ passSms.ok = true;
1748
+ passSms.result = res?.message || "Sent.";
1749
+ } catch (error: any) {
1750
+ passSms.ok = false;
1751
+ passSms.result = error?.data?.message || "The SMS could not be sent. Please try again in a minute.";
1752
+ } finally {
1753
+ passSms.sending = false;
1754
+ }
1755
+ }
1676
1756
  const hidQrRemainingSeconds = computed(() => {
1677
1757
  const expiry = new Date(hidQrExpiresAt.value).getTime();
1678
1758
  return Number.isFinite(expiry) ? Math.max(0, Math.ceil((expiry - hidQrNow.value) / 1000)) : 0;
@@ -1683,6 +1763,7 @@ async function loadHidQrConfig() {
1683
1763
  try {
1684
1764
  const response: any = await getSiteById(siteId);
1685
1765
  const site = response?.data ?? response;
1766
+ passSmsEnabled.value = isVisitorPassSmsOn(site);
1686
1767
  const config = site?.metadata?.hidQrCodePass ?? {};
1687
1768
  hidQrConfig.value = {
1688
1769
  enabled: Boolean(config.enabled && config.onlineMode !== false),
@@ -1690,6 +1771,7 @@ async function loadHidQrConfig() {
1690
1771
  validityMinutes: Number(config.validityMinutes) > 0 ? Number(config.validityMinutes) : 60,
1691
1772
  };
1692
1773
  } catch {
1774
+ passSmsEnabled.value = false;
1693
1775
  hidQrConfig.value = { enabled: false, readerId: "", validityMinutes: 60 };
1694
1776
  }
1695
1777
  }
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <div data-test="visitor-pass-sms-settings">
3
+ <v-switch v-model="enabled" :disabled="readOnly" label="Send visitor pass by SMS" color="primary" hide-details
4
+ data-test="visitor-pass-sms-switch" />
5
+ <p class="text-caption text-medium-emphasis mt-1 mb-3">
6
+ Staff can text an approved visitor their pass link (the QR they show at the guardhouse). The text has the site
7
+ name, the visit date and the link only.
8
+ </p>
9
+ <v-btn v-if="!readOnly" class="screen-btn-primary" color="primary-button" variant="flat" text="Save"
10
+ :loading="saving" :disabled="!loaded" data-test="visitor-pass-sms-save" @click="save" />
11
+ <Snackbar v-model="toast.show" :text="toast.message" :color="toast.color" />
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import useSiteFeatureSettings from "../composables/useSiteFeatureSettings";
17
+
18
+ /**
19
+ * Site setting `metadata.visitorPassSms` (core site-feature-settings).
20
+ * Off = today: no "Send pass by SMS" action anywhere.
21
+ */
22
+ const props = defineProps({
23
+ siteId: { type: String, required: true },
24
+ saved: { type: Object as PropType<{ enabled?: boolean } | null>, default: null },
25
+ readOnly: { type: Boolean, default: false },
26
+ /** The site has been read; Save stays off until then. */
27
+ loaded: { type: Boolean, default: false },
28
+ });
29
+ const emit = defineEmits(["saved"]);
30
+
31
+ const enabled = ref(false);
32
+ watch(
33
+ () => props.saved,
34
+ (v) => {
35
+ enabled.value = v?.enabled === true;
36
+ },
37
+ { immediate: true },
38
+ );
39
+
40
+ const { saveSiteFeature } = useSiteFeatureSettings();
41
+ const saving = ref(false);
42
+ const toast = reactive({ show: false, message: "", color: "" });
43
+
44
+ async function save() {
45
+ if (!props.loaded) return;
46
+ saving.value = true;
47
+ try {
48
+ await saveSiteFeature(props.siteId, "visitorPassSms", { enabled: enabled.value });
49
+ Object.assign(toast, { show: true, message: "Saved.", color: "success" });
50
+ emit("saved");
51
+ } catch (e: any) {
52
+ Object.assign(toast, { show: true, message: e?.data?.message || "Could not save.", color: "error" });
53
+ } finally {
54
+ saving.value = false;
55
+ }
56
+ }
57
+ </script>
@@ -83,6 +83,17 @@ export default function useCleaningPermission() {
83
83
  description: "Allows the user to manage and update site settings.",
84
84
  },
85
85
  },
86
+ // HID access, user side only (decision of 2026-10-16). The service apps
87
+ // have no HID admin screens yet, so a role here can be prepared with the
88
+ // one string that lets a member use their own QR code, face, PIN, card and
89
+ // intercom. Mirrored from core `src/utils/hid-access.util.ts`.
90
+ "hid-mgmt": {
91
+ "use-hid-access": {
92
+ check: true,
93
+ description:
94
+ "Allows the user to see HID Access in the app and use their own QR code, face, PIN, card and intercom at this site.",
95
+ },
96
+ },
86
97
  toilet_locations: {
87
98
  "create-toilet-location": {
88
99
  check: true,