@7365admin1/layer-common 4.97.1-staging.569 → 4.97.1-staging.570

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.
@@ -622,6 +622,7 @@ import useSiteEntryPassSettings from "../composables/useSiteEntryPassSettings";
622
622
  import useAccessManagement from "../composables/useAccessManagement";
623
623
  import usePeople from "../composables/usePeople";
624
624
  import useHidAmico from "../composables/useHidAmico";
625
+ import { minutesUntilEndOfDay } from "../utils/hid-qr-validity";
625
626
 
626
627
  const prop = defineProps({
627
628
  type: {
@@ -947,11 +948,6 @@ const hidQrTemplate = computed(() => {
947
948
  return hidQrCodePassConfig.value?.template || {};
948
949
  });
949
950
 
950
- const hidQrValidityMinutes = computed(() => {
951
- const value = Number(hidQrCodePassConfig.value?.validityMinutes);
952
- return Number.isFinite(value) && value > 0 ? value : 60;
953
- });
954
-
955
951
  const hidQrConfiguredReaderId = computed(() => String(hidQrCodePassConfig.value?.readerId || ""));
956
952
  type HidQrReaderSummary = {
957
953
  _id: string;
@@ -973,7 +969,7 @@ const hidQrReaderId = computed(() => (
973
969
  * `hidQrCodePassAllowed`, which is why the switch belongs here and not in each
974
970
  * of them.
975
971
  */
976
- const HID_VISITOR_QR_ENABLED = false;
972
+ const HID_VISITOR_QR_ENABLED = true;
977
973
 
978
974
  const hidQrCodePassAllowed = computed(() => {
979
975
  return (
@@ -2299,7 +2295,9 @@ async function prepareHidQrCodePreview(visitorId: string) {
2299
2295
  hidQrVisitorId.value = visitorId;
2300
2296
  const response = await issueVisitorQr(hidQrReaderId.value, {
2301
2297
  visitorId,
2302
- validityMinutes: hidQrValidityMinutes.value,
2298
+ // The whole visit day, as the resident app issues it. Worked out per
2299
+ // call so a regenerate later in the day still ends at midnight.
2300
+ validityMinutes: minutesUntilEndOfDay(),
2303
2301
  });
2304
2302
  const credential = "data" in response ? response.data : response;
2305
2303
  hidQrPrintPayload.value = credential.qrValue;
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.97.1-staging.569",
5
+ "version": "4.97.1-staging.570",
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.",
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Minutes from `now` to the next local midnight, so a visitor HID QR runs to
3
+ * the end of the visit day. The resident app's invite form does the same
4
+ * (`minutesUntilEndOfDay` in its VisitorForm.tsx). Never less than 1: the API
5
+ * refuses a zero validity.
6
+ */
7
+ export function minutesUntilEndOfDay(now: Date = new Date()) {
8
+ const midnight = new Date(now);
9
+ midnight.setHours(24, 0, 0, 0);
10
+ return Math.max(1, Math.floor((midnight.getTime() - now.getTime()) / 60_000));
11
+ }