@7365admin1/layer-common 4.32.0 → 4.32.1-staging.364

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 +4 -4
  2. package/components/AccessCardAddForm.vue +5 -4
  3. package/components/AccessCardAssignToUnitForm.vue +3 -2
  4. package/components/AccessCardPreviewDialog.vue +4 -3
  5. package/components/Dialog/DeleteConfirmation.vue +17 -2
  6. package/components/Dialog/ReusablePrompt.vue +26 -3
  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/EntryPass/QrTemplatePreview.vue +21 -25
  11. package/components/EntryPassInformation.vue +119 -24
  12. package/components/Facility/BookingSetup.vue +63 -0
  13. package/components/HidAccessLogDashboard.vue +41 -8
  14. package/components/HidAccessPermissions.vue +424 -0
  15. package/components/HidIntercomManagement.vue +148 -14
  16. package/components/HidProfileQrCode.vue +332 -0
  17. package/components/HidReaderManagement.vue +26 -0
  18. package/components/HidReaderUserRoster.vue +44 -3
  19. package/components/HidUserEnrollment.vue +845 -155
  20. package/components/InvitationClientForm.vue +19 -1
  21. package/components/NotificationBell.vue +39 -3
  22. package/components/VehicleForm.vue +45 -2
  23. package/components/VehicleManagement.vue +95 -10
  24. package/components/VisitorManagement.vue +267 -5
  25. package/composables/useAccessManagement.ts +5 -0
  26. package/composables/useCleaningPermission.ts +4 -4
  27. package/composables/useCommonPermission.ts +16 -0
  28. package/composables/useDocument.ts +7 -0
  29. package/composables/useFacility.ts +11 -0
  30. package/composables/useHidAmico.ts +117 -0
  31. package/composables/useHidNavigation.ts +25 -1
  32. package/composables/useHidReaderSelection.ts +50 -0
  33. package/composables/useLandscapingPermission.ts +4 -4
  34. package/composables/useMechanicalElectricalPermission.ts +4 -4
  35. package/composables/usePeople.ts +19 -0
  36. package/composables/usePestControlPermission.ts +4 -4
  37. package/composables/usePoolMaintenancePermission.ts +4 -4
  38. package/composables/useSecurityPermission.ts +4 -10
  39. package/composables/useSiteCategory.ts +45 -0
  40. package/composables/useSiteEntryPassSettings.ts +26 -0
  41. package/composables/useWebUsb.ts +14 -11
  42. package/package.json +1 -1
  43. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  44. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  45. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  46. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  47. package/types/document.d.ts +14 -0
  48. package/types/facility.d.ts +4 -0
  49. package/types/people.d.ts +28 -1
  50. package/utils/hid-permission-assignments.ts +190 -0
  51. package/utils/hid-reader-selection.ts +52 -0
  52. package/utils/notification-target.ts +75 -0
  53. package/utils/occupancy-role.ts +109 -0
  54. package/utils/vehicle-actions.ts +12 -4
@@ -388,9 +388,27 @@ watch(
388
388
  const roles = ref<any[]>([])
389
389
  const { getRoles } = useRole()
390
390
 
391
+ /*
392
+ * `type` is the ROLE type, not the service the client subscribes to, and the
393
+ * only caller (`ClientMain.vue` "Invite Client") passes no `app` prop -- so
394
+ * this sent `type: ""` and the endpoint applied no type filter at all. The
395
+ * dropdown therefore listed every org-less role of every type, which includes
396
+ * the platform's OWN staff roles (`type: "admin"` -- the two rows the console's
397
+ * `/super-admin/role-permissions` screen edits). Offering a Seven365 console
398
+ * staff role on a CLIENT invitation is the defect.
399
+ *
400
+ * A client admin's role is `type: "organization"`, which is what the client
401
+ * roles screen (`org/[organization]/roles-permissions.vue`) already lists. This
402
+ * narrows to exactly that. It is a narrowing of this one picker only: no role
403
+ * changes, no permission changes, and the org-less `organization` roles that
404
+ * were already being picked are all still offered.
405
+ *
406
+ * Keying off the selected service instead would empty the dropdown -- no
407
+ * org-less role carries a service type -- so `props.app` is not the filter.
408
+ */
391
409
  const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
392
410
  "roles",
393
- () => getRoles({ org: org.value?._id, type: props.app, limit: 50 }),
411
+ () => getRoles({ org: org.value?._id, type: "organization", limit: 50 }),
394
412
  { watch: [() => props.app] }
395
413
  )
396
414
 
@@ -134,6 +134,7 @@ import {
134
134
  timeAgo,
135
135
  type TInboxItem,
136
136
  } from "../utils/notification-inbox";
137
+ import { notificationTarget } from "../utils/notification-target";
137
138
 
138
139
  /**
139
140
  * The top-bar notification feed for the web, in every signed-in app.
@@ -165,6 +166,8 @@ defineProps({
165
166
 
166
167
  const { getAll, getUnreadCount, markAsRead, markAllAsRead } = useNotification();
167
168
  const { currentUser } = useLocalAuth();
169
+ const route = useRoute();
170
+ const router = useRouter();
168
171
 
169
172
  const open = ref(false);
170
173
  const loading = ref(false);
@@ -269,16 +272,49 @@ function announce(fresh: TInboxItem[]) {
269
272
  }
270
273
  }
271
274
 
275
+ /**
276
+ * Clicking a row does two separate things, and the second one is why the row is
277
+ * a button at all: mark it read, and go to what it is about.
278
+ *
279
+ * They are kept apart deliberately. Marking read is best-effort and reverts on
280
+ * failure; navigation must not wait on that round trip, and must still happen
281
+ * for a row that was ALREADY read — a person re-opening the bell to find the
282
+ * order they were told about is the ordinary case, and the old early-return on
283
+ * `hasRead` would have sent them nowhere.
284
+ */
272
285
  async function openNotification(item: Record<string, any>) {
286
+ markRead(item);
287
+ await goToSubject(item);
288
+ }
289
+
290
+ function markRead(item: Record<string, any>) {
273
291
  if (item.hasRead) return;
274
292
  // Marked locally first: waiting on a round trip to move the dot reads as a dead control.
275
293
  item.hasRead = true;
276
294
  unread.value = Math.max(0, unread.value - 1);
277
- try {
278
- await markAsRead(String(item._id), userId.value);
279
- } catch {
295
+ markAsRead(String(item._id), userId.value).catch(() => {
280
296
  item.hasRead = false;
281
297
  unread.value += 1;
298
+ });
299
+ }
300
+
301
+ /**
302
+ * `hasRoute` is the whole reason an org-app route name may live in the shared
303
+ * layer: the ten apps that have no order queue simply do not match it, and the
304
+ * click there stays what it always was.
305
+ */
306
+ async function goToSubject(item: Record<string, any>) {
307
+ const target = notificationTarget(item as any, {
308
+ organization: String(route.params?.organization ?? ""),
309
+ });
310
+ if (!target) return;
311
+ if (typeof router.hasRoute !== "function" || !router.hasRoute(target.name)) return;
312
+
313
+ open.value = false;
314
+ try {
315
+ await router.push(target);
316
+ } catch {
317
+ // A cancelled or duplicate navigation is not worth an error in the top bar.
282
318
  }
283
319
  }
284
320
 
@@ -396,7 +396,10 @@
396
396
  to find out why. The click now runs the validation, which paints every
397
397
  offending field and writes the reason above.
398
398
  -->
399
- <AppButton :disabled="processing" @click="submit">
399
+ <!-- Refused by the server for want of the right: drawn disabled, and a
400
+ press only repeats the reason - nothing is sent again. -->
401
+ <AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
402
+ :aria-disabled="!!refusedMessage || undefined" @click="submit">
400
403
  {{ prop.mode == "add" ? "Submit" : "Update" }}
401
404
  </AppButton>
402
405
  </div>
@@ -440,7 +443,8 @@
440
443
  </div>
441
444
  <div class="vehicle-form__footer">
442
445
  <AppButton variant="ghost" :disabled="processing" @click="cancelExistingUpdate">Cancel</AppButton>
443
- <AppButton :disabled="processing" @click="confirmExistingUpdate">Update</AppButton>
446
+ <AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
447
+ :aria-disabled="!!refusedMessage || undefined" @click="confirmExistingUpdate">Update</AppButton>
444
448
  </div>
445
449
  </v-card>
446
450
  </v-dialog>
@@ -517,6 +521,7 @@
517
521
 
518
522
  <script setup lang="ts">
519
523
  import { errorConverter } from "../utils/data";
524
+ import { isPermissionRefusalError } from "../utils/permission-refusal";
520
525
  const prop = defineProps({
521
526
  type: {
522
527
  type: String as PropType<TVehicleType | "seasonpass">,
@@ -597,8 +602,28 @@ const emit = defineEmits([
597
602
  "error",
598
603
  "close",
599
604
  "close:all",
605
+ // The server refused for want of the right: "create" or "update".
606
+ "refused",
600
607
  ]);
601
608
 
609
+ /**
610
+ * The server's "You do not have permission to ..." once it has refused this
611
+ * form. From then on the confirm is drawn disabled and a press only shows the
612
+ * sentence again - no second request. The host is told (`refused`) so it can
613
+ * take the matching action off its menus.
614
+ */
615
+ const refusedMessage = ref("");
616
+ function noteRefusal(error: unknown) {
617
+ if (!isPermissionRefusalError(error)) return;
618
+ refusedMessage.value = errorMessage.value;
619
+ emit("refused", prop.mode === "add" ? "create" : "update");
620
+ }
621
+ function refusedAlready() {
622
+ if (!refusedMessage.value) return false;
623
+ errorMessage.value = refusedMessage.value;
624
+ return true;
625
+ }
626
+
602
627
  const vehicle = reactive<
603
628
  Omit<ExceptPartial<TVehicle>, "type"> & { type: TVehicleType | "seasonpass" }
604
629
  >({
@@ -1142,6 +1167,10 @@ function cancelExistingUpdate() {
1142
1167
  async function confirmExistingUpdate() {
1143
1168
  const payload = pendingPayload.value;
1144
1169
  if (!payload) return;
1170
+ if (refusedAlready()) {
1171
+ showExistingDialog.value = false;
1172
+ return;
1173
+ }
1145
1174
 
1146
1175
  errorMessage.value = "";
1147
1176
  processing.value = true;
@@ -1168,12 +1197,14 @@ async function confirmExistingUpdate() {
1168
1197
  // Shown under the form. A record moved before the failure stays moved.
1169
1198
  showExistingDialog.value = false;
1170
1199
  errorMessage.value = errorConverter(error);
1200
+ noteRefusal(error);
1171
1201
  } finally {
1172
1202
  processing.value = false;
1173
1203
  }
1174
1204
  }
1175
1205
 
1176
1206
  async function submit() {
1207
+ if (refusedAlready()) return;
1177
1208
  errorMessage.value = "";
1178
1209
 
1179
1210
  // Ask the form first. `validate()` marks each failing field, so the person
@@ -1326,6 +1357,7 @@ async function submit() {
1326
1357
  // with nothing), returns a plain sentence instead of ofetch's
1327
1358
  // `[POST] "/api/vehicles": 502`.
1328
1359
  errorMessage.value = errorConverter(error);
1360
+ noteRefusal(error);
1329
1361
  } finally {
1330
1362
  processing.value = false;
1331
1363
  }
@@ -1508,6 +1540,12 @@ function handleCloseMatchDialog() {
1508
1540
  // The panel's own close button never did that; the two now agree. Backing out
1509
1541
  // of a picker is not a decision to discard what you already had.
1510
1542
  showMatchingPeopleDialog.value = false;
1543
+ // Closed WITHOUT picking a record: the person is someone new at this unit,
1544
+ // so NRIC and Full Name are typed in by hand. They were left locked by the
1545
+ // lookup (`disablePrefilledInputs`), with no way to unlock them short of
1546
+ // choosing a different unit. A picked record still locks them
1547
+ // (`selectPeopleRecord`).
1548
+ if (!vehicle.peopleId) disablePrefilledInputs.value = false;
1511
1549
  }
1512
1550
 
1513
1551
  onMounted(() => {
@@ -1547,6 +1585,11 @@ onMounted(() => {
1547
1585
  });
1548
1586
  </script>
1549
1587
  <style scoped>
1588
+ /* Refused: faded, but still takes the click so it can say why. */
1589
+ .no-permission {
1590
+ opacity: 0.45;
1591
+ cursor: not-allowed;
1592
+ }
1550
1593
  .button-outline-class {
1551
1594
  border: 1px solid rgba(var(--v-theme-primary));
1552
1595
  }
@@ -20,6 +20,16 @@
20
20
  show-header @row-click="handleRowClick"
21
21
  @update:page="handleUpdatePage">
22
22
 
23
+ <!-- Empty table: say WHY when the server refused the list ("You do not
24
+ have permission to view vehicles."), rather than "No data
25
+ available", which reads as an empty site. -->
26
+ <template #no-data>
27
+ <div class="table-card__empty" :class="{ 'text-error': !!listError }">
28
+ <v-icon :icon="listError ? 'mdi-lock-outline' : 'mdi-magnify-close'" size="32" />
29
+ <span>{{ listError || "No data available" }}</span>
30
+ </div>
31
+ </template>
32
+
23
33
  <!-- Residents / Season Passes / Block Listed, on the toolbar row the way
24
34
  the other screens draw their tabs. Each tab shows every status. -->
25
35
  <template #tabs>
@@ -115,19 +125,19 @@
115
125
  <v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
116
126
  <VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
117
127
  :plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
118
- :org="org" :site="props.site" @close:all="handleCloseAll" />
128
+ :org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" />
119
129
  </v-dialog>
120
130
 
121
131
  <v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
122
132
  <VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedPlateNumberObject"
123
133
  :plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
124
- :org="org" :site="props.site" @close:all="handleCloseAll" @close="handleCloseAll" />
134
+ :org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" @close="handleCloseAll" />
125
135
  </v-dialog>
126
136
 
127
137
  <!-- <v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
128
138
  <VehicleForm :type="vehicleType" mode="edit" :vehicle-data="selectedVehicleObject"
129
139
  @back="dialog.updateVehicle = false" @close="dialog.updateVehicle = false" @done="handleUpdateVehicleComplete"
130
- :org="org" :site="site" @close:all="handleCloseAll" />
140
+ :org="org" :site="site" @close:all="handleCloseAll" @refused="handleFormRefused" />
131
141
  </v-dialog> -->
132
142
 
133
143
  <v-dialog v-if="canViewVehicleDetails" v-model="dialog.showMoreActions" width="800" persistent>
@@ -244,7 +254,7 @@
244
254
  when the ANPR revoke could not be confirmed - the dialog stays open on
245
255
  that path so the operator can read it and retry.
246
256
  -->
247
- <DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError"
257
+ <DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError" :no-permission="revoked.delete"
248
258
  :prompt-title="`Remove vehicle number ${selectedPlateNumberObject?.plateNumber} from this record? This revokes its ANPR access - it will no longer open the barrier. The resident and any other vehicle numbers on this record are not affected.`"
249
259
  @delete="submitDelete" @close="closeDeleteDialog" />
250
260
  </v-dialog>
@@ -255,24 +265,26 @@
255
265
  operator has to read and act on - it was going to a five-second
256
266
  snackbar, along with the device's raw `{"ErrorCode":...}` reply.
257
267
  -->
258
- <DialogReusablePrompt :loading="approvingVehicle" :message="actionError"
268
+ <DialogReusablePrompt :loading="approvingVehicle" :message="actionError" message-error :no-permission="revoked.approve"
259
269
  :prompt-title="`Are you sure want to approve this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
260
270
  @proceed="submitApprove" @close="closeActionDialog('approveVehicle')" />
261
271
  </v-dialog>
272
+ <!-- Like Delete, Restore says what it does at the barrier: a whitelist
273
+ plate goes back on the allowed list and opens it again. -->
262
274
  <v-dialog v-model="dialog.restoreVehicle" persistent width="540">
263
- <DialogReusablePrompt :loading="restoringVehicle" :message="actionError"
264
- :prompt-title="`Are you sure want to restore this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
275
+ <DialogReusablePrompt :loading="restoringVehicle" :message="actionError" message-error :no-permission="revoked.approve"
276
+ :prompt-title="restorePrompt"
265
277
  @proceed="submitRestore" @close="closeActionDialog('restoreVehicle')" />
266
278
  </v-dialog>
267
279
  <!-- Block / Unblock say what happens on the cameras, because that is the
268
280
  part the operator cannot see from here. -->
269
281
  <v-dialog v-model="dialog.blockVehicle" persistent width="540">
270
- <DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
282
+ <DialogReusablePrompt :loading="blockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
271
283
  :prompt-title="`Block vehicle ${selectedPlateNumberObject?.plateNumber}? It is added to every ANPR camera's blocklist and taken off the allowed list. Its status becomes Blocked and its category Block Listed.`"
272
284
  @proceed="submitBlock" @close="closeActionDialog('blockVehicle')" />
273
285
  </v-dialog>
274
286
  <v-dialog v-model="dialog.unblockVehicle" persistent width="540">
275
- <DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
287
+ <DialogReusablePrompt :loading="unblockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
276
288
  :prompt-title="`Unblock vehicle ${selectedPlateNumberObject?.plateNumber}? It is taken off every ANPR camera's blocklist. It is NOT whitelisted - the record stays with status Unblocked.`"
277
289
  @proceed="submitUnblock" @close="closeActionDialog('unblockVehicle')" />
278
290
  </v-dialog>
@@ -629,7 +641,7 @@ const nameHints = computed<Record<string, string>>(() => {
629
641
  return hints;
630
642
  })
631
643
 
632
- const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending } =
644
+ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending, error: getVehiclesError } =
633
645
  await useLazyAsyncData(
634
646
  `get-all-vehicles-${props.site}`,
635
647
  () =>
@@ -645,6 +657,18 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
645
657
  );
646
658
 
647
659
 
660
+ /** The server's reason when the list itself was refused or failed. */
661
+ const listError = computed(() =>
662
+ getVehiclesError.value ? errorConverter(getVehiclesError.value) : "",
663
+ );
664
+ watch(getVehiclesError, (error) => {
665
+ // A refused list must not keep showing the rows from before the refusal.
666
+ if (!error) return;
667
+ items.value = [];
668
+ pages.value = 0;
669
+ pageRange.value = "-- - -- of --";
670
+ });
671
+
648
672
  watch(getVehiclesReq, (newData: any) => {
649
673
  loadActiveCameraCounts();
650
674
  items.value = newData?.items || [];
@@ -653,6 +677,12 @@ watch(getVehiclesReq, (newData: any) => {
653
677
  })
654
678
 
655
679
  function handleRowClick(data: any) {
680
+ // Without "See Vehicle Details" the Preview dialog is not rendered at all,
681
+ // so a click used to do nothing and gave no reason. Say why instead.
682
+ if (!props.canViewVehicleDetails) {
683
+ showMessage("You do not have permission to view vehicle details.", "error");
684
+ return;
685
+ }
656
686
  selectedVehicleId.value = data?.item?._id;
657
687
  dialog.showMoreActions = true;
658
688
  message.value = "";
@@ -829,6 +859,29 @@ function revokeOnRefusal(error: unknown, right: keyof typeof revoked) {
829
859
  if (isPermissionRefusalError(error)) revoked[right] = true;
830
860
  }
831
861
 
862
+ /** The server's own sentences, reused so a repeat press sends nothing. */
863
+ const NO_PERMISSION: Record<keyof typeof revoked, string> = {
864
+ update: "You do not have permission to edit vehicles.",
865
+ delete: "You do not have permission to delete vehicles.",
866
+ approve: "You do not have permission to approve vehicles.",
867
+ };
868
+
869
+ /**
870
+ * True (and the reason shown in the dialog) when this right was already
871
+ * refused: the confirm is drawn disabled, and pressing it again only repeats
872
+ * the message - no request goes to the server.
873
+ */
874
+ /** The add/edit form was refused: an edit refusal takes Edit/Block/Unblock off. */
875
+ function handleFormRefused(kind: "create" | "update") {
876
+ if (kind === "update") revoked.update = true;
877
+ }
878
+
879
+ function refusedAlready(right: keyof typeof revoked, target: typeof actionError) {
880
+ if (!revoked[right]) return false;
881
+ target.value = NO_PERMISSION[right];
882
+ return true;
883
+ }
884
+
832
885
  /**
833
886
  * One entry point for every menu item, in both menus, so a new action can only
834
887
  * be added in one place and cannot be forgotten in the other.
@@ -910,6 +963,7 @@ const formatPlateNumbers = (value: any) => {
910
963
  };
911
964
 
912
965
  async function submitDelete() {
966
+ if (refusedAlready("delete", deleteError)) return;
913
967
 
914
968
  const plateNumberId = selectedPlateNumberObject.value?._id;
915
969
  const type = selectedPlateNumberObject.value?.type as TVehicleType;
@@ -945,7 +999,33 @@ async function submitDelete() {
945
999
 
946
1000
 
947
1001
 
1002
+ /**
1003
+ * What Restore will do on the cameras, from the site's live camera counts:
1004
+ * a whitelist plate (or season pass) goes back on the allowed list and opens
1005
+ * the barrier again; a blocklist plate goes back on the blocklist.
1006
+ */
1007
+ const restorePrompt = computed(() => {
1008
+ const plate = selectedPlateNumberObject.value;
1009
+ const number = plate?.plateNumber ?? "";
1010
+ const blocklist = String(plate?.type ?? "").toLowerCase() === "blocklist";
1011
+ const counts = activeCameraCounts.value;
1012
+ const cameras = counts ? (blocklist ? counts.blocked : counts.allowed) : null;
1013
+ const onCameras =
1014
+ cameras === null
1015
+ ? "every ANPR camera"
1016
+ : `${cameras} ANPR camera${cameras === 1 ? "" : "s"}`;
1017
+
1018
+ if (cameras === 0) {
1019
+ return `Restore vehicle ${number}? There is no active ANPR camera for it at this site, so barrier access does not change until one is added.`;
1020
+ }
1021
+ if (blocklist) {
1022
+ return `Restore vehicle ${number}? It is added back to the blocklist on ${onCameras} - the barrier will stay closed for it. Its status becomes Blocked.`;
1023
+ }
1024
+ return `Restore vehicle ${number}? This gives back its ANPR access on ${onCameras} - it will open the barrier again. Only this vehicle number is affected.`;
1025
+ });
1026
+
948
1027
  async function submitRestore() {
1028
+ if (refusedAlready("approve", actionError)) return;
949
1029
 
950
1030
  const vehicleId = selectedPlateNumberObject.value?._id;
951
1031
 
@@ -965,6 +1045,8 @@ async function submitRestore() {
965
1045
  await getVehiclesRefresh();
966
1046
  } catch (error: any) {
967
1047
  actionError.value = errorConverter(error);
1048
+ // Restore is the approve endpoint: a refusal is the Approve right gone.
1049
+ revokeOnRefusal(error, "approve");
968
1050
  } finally {
969
1051
  restoringVehicle.value = false;
970
1052
  }
@@ -972,6 +1054,7 @@ async function submitRestore() {
972
1054
 
973
1055
 
974
1056
  async function submitBlock() {
1057
+ if (refusedAlready("update", actionError)) return;
975
1058
  const vehicleId = selectedPlateNumberObject.value?._id;
976
1059
  if (!vehicleId) {
977
1060
  showMessage("Invalid vehicle selected for blocking.", "error");
@@ -995,6 +1078,7 @@ async function submitBlock() {
995
1078
 
996
1079
 
997
1080
  async function submitUnblock() {
1081
+ if (refusedAlready("update", actionError)) return;
998
1082
  const vehicleId = selectedPlateNumberObject.value?._id;
999
1083
  if (!vehicleId) {
1000
1084
  showMessage("Invalid vehicle selected for unblocking.", "error");
@@ -1018,6 +1102,7 @@ async function submitUnblock() {
1018
1102
 
1019
1103
 
1020
1104
  async function submitApprove() {
1105
+ if (refusedAlready("approve", actionError)) return;
1021
1106
 
1022
1107
  const plateNumberId = selectedPlateNumberObject.value?._id;
1023
1108
  if (!plateNumberId) {