@7365admin1/layer-common 1.9.0 → 1.10.1

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 (93) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/AcceptDialog.vue +44 -0
  3. package/components/AccessCardAddForm.vue +101 -13
  4. package/components/AccessManagement.vue +130 -47
  5. package/components/AddSupplyForm.vue +165 -0
  6. package/components/AreaChecklistHistoryLogs.vue +235 -0
  7. package/components/AreaChecklistHistoryMain.vue +176 -0
  8. package/components/AreaFormDialog.vue +266 -0
  9. package/components/AreaMain.vue +841 -0
  10. package/components/AttendanceCheckInOutDialog.vue +416 -0
  11. package/components/AttendanceDetailsDialog.vue +184 -0
  12. package/components/AttendanceMain.vue +155 -0
  13. package/components/AttendanceMapSearchDialog.vue +393 -0
  14. package/components/AttendanceSettingsDialog.vue +398 -0
  15. package/components/BuildingManagement/buildings.vue +5 -5
  16. package/components/BuildingManagement/units.vue +5 -5
  17. package/components/ChecklistItemRow.vue +54 -0
  18. package/components/CheckoutItemMain.vue +705 -0
  19. package/components/CleaningScheduleMain.vue +271 -0
  20. package/components/DocumentManagement.vue +8 -9
  21. package/components/EntryPass/QrTemplatePreview.vue +104 -0
  22. package/components/EntryPassMain.vue +252 -200
  23. package/components/HygieneUpdateMoreAction.vue +238 -0
  24. package/components/IncidentReport/Authorities.vue +226 -0
  25. package/components/IncidentReport/IncidentInformation.vue +258 -0
  26. package/components/IncidentReport/affectedEntities.vue +167 -0
  27. package/components/InvitationMain.vue +19 -17
  28. package/components/ManageChecklistMain.vue +384 -0
  29. package/components/MemberMain.vue +48 -20
  30. package/components/MyAttendanceMain.vue +224 -0
  31. package/components/OnlineFormsConfiguration.vue +9 -2
  32. package/components/PasswordConfirmation.vue +95 -0
  33. package/components/PhotoUpload.vue +410 -0
  34. package/components/RolePermissionMain.vue +17 -15
  35. package/components/ScheduleAreaMain.vue +313 -0
  36. package/components/ScheduleTaskAreaFormDialog.vue +144 -0
  37. package/components/ScheduleTaskAreaUpdateMoreAction.vue +109 -0
  38. package/components/ScheduleTaskForm.vue +471 -0
  39. package/components/ScheduleTaskMain.vue +345 -0
  40. package/components/ScheduleTastTicketMain.vue +182 -0
  41. package/components/ServiceProviderMain.vue +27 -7
  42. package/components/StockCard.vue +191 -0
  43. package/components/SupplyManagementMain.vue +557 -0
  44. package/components/TableHygiene.vue +617 -0
  45. package/components/UnitMain.vue +451 -0
  46. package/components/VisitorManagement.vue +28 -15
  47. package/composables/useAccessManagement.ts +90 -0
  48. package/composables/useAreaPermission.ts +51 -0
  49. package/composables/useAreas.ts +99 -0
  50. package/composables/useAttendance.ts +89 -0
  51. package/composables/useAttendancePermission.ts +68 -0
  52. package/composables/useBuilding.ts +2 -2
  53. package/composables/useBuildingUnit.ts +2 -2
  54. package/composables/useCard.ts +2 -0
  55. package/composables/useCheckout.ts +61 -0
  56. package/composables/useCheckoutPermission.ts +80 -0
  57. package/composables/useCleaningPermission.ts +229 -0
  58. package/composables/useCleaningSchedulePermission.ts +58 -0
  59. package/composables/useCleaningSchedules.ts +233 -0
  60. package/composables/useCountry.ts +8 -0
  61. package/composables/useDOBEntries.ts +13 -0
  62. package/composables/useDashboardData.ts +2 -2
  63. package/composables/useDocument.ts +3 -2
  64. package/composables/useFeedback.ts +1 -1
  65. package/composables/useFile.ts +4 -6
  66. package/composables/useLocation.ts +78 -0
  67. package/composables/useOnlineForm.ts +16 -9
  68. package/composables/usePeople.ts +87 -72
  69. package/composables/useQR.ts +29 -0
  70. package/composables/useRole.ts +3 -2
  71. package/composables/useScheduleTask.ts +89 -0
  72. package/composables/useScheduleTaskArea.ts +85 -0
  73. package/composables/useScheduleTaskPermission.ts +68 -0
  74. package/composables/useSiteEntryPassSettings.ts +4 -15
  75. package/composables/useStock.ts +45 -0
  76. package/composables/useSupply.ts +63 -0
  77. package/composables/useSupplyPermission.ts +92 -0
  78. package/composables/useUnitPermission.ts +51 -0
  79. package/composables/useUnits.ts +82 -0
  80. package/composables/useWebUsb.ts +389 -0
  81. package/composables/useWorkOrder.ts +1 -1
  82. package/nuxt.config.ts +3 -0
  83. package/package.json +4 -1
  84. package/types/area.d.ts +22 -0
  85. package/types/attendance.d.ts +38 -0
  86. package/types/checkout-item.d.ts +27 -0
  87. package/types/cleaner-schedule.d.ts +54 -0
  88. package/types/location.d.ts +42 -0
  89. package/types/schedule-task.d.ts +18 -0
  90. package/types/stock.d.ts +16 -0
  91. package/types/supply.d.ts +11 -0
  92. package/types/verification.d.ts +1 -1
  93. package/utils/acm-crypto.ts +30 -0
@@ -8,7 +8,7 @@
8
8
  <v-row no-gutters class="" v-if="!loading">
9
9
  <v-col cols="12" elevation="3" class="border">
10
10
  <v-row no-gutters class="px-6 pt-4">
11
- <div class="d-flex mt-7 pb-5">
11
+ <!-- <div class="d-flex mt-7 pb-5">
12
12
  <p class="mr-6 font-weight-medium flex-grow-1">
13
13
  Physical / Key Pass
14
14
  <span class="d-block text-caption text-grey-darken-1 mt-1">
@@ -25,8 +25,8 @@
25
25
  @update:modelValue="updateEntryPassSettingsPhysicalPass()"
26
26
  ></v-switch>
27
27
  </div>
28
- <v-divider thickness="1"></v-divider>
29
- <div class="d-flex mt-7 pb-5">
28
+ <v-divider thickness="1"></v-divider> -->
29
+ <div class="d-flex mt-7 pb-5 pr-5">
30
30
  <p class="mr-6 font-weight-medium flex-grow-1">
31
31
  NFC / QR Code Pass
32
32
  <span class="d-block text-caption text-grey-darken-1 mt-1">
@@ -46,35 +46,60 @@
46
46
  </div>
47
47
  <v-divider thickness="1"></v-divider>
48
48
  <div class="d-flex w-100 mt-7 pb-10">
49
- <p class="mr-6 font-weight-medium flex-grow-1">
49
+ <p class="font-weight-medium flex-grow-1">
50
50
  Upload Access Cards Template
51
51
  <span class="d-block text-caption text-grey-darken-1 mt-1">
52
52
  <a
53
- target="_blank"
53
+ v-if="currentEntryPassSettings.template?.id"
54
+ href="#"
54
55
  class="text-truncate d-flex items-center text-decoration-none"
55
- href=""
56
+ @click.prevent="downloadTemplate"
56
57
  >
57
- <v-icon class="mr-2" size="24px"> mdi-paperclip </v-icon>
58
- template
58
+ <v-icon class="mr-2" size="24px">mdi-paperclip</v-icon>
59
+ {{ currentEntryPassSettings.template.name }}
59
60
  </a>
60
61
  </span>
61
62
  </p>
62
- <v-btn
63
- variant="flat"
64
- color="error"
65
- size="small"
66
- style="height: 40px; margin-left: auto"
67
- prepend-icon="mdi-file-document-remove-outline"
68
- >
69
- Remove
70
- </v-btn>
63
+ <div class="d-flex align-center" style="margin-left: auto; gap: 8px">
64
+ <v-btn
65
+ v-if="!currentEntryPassSettings.template?.id"
66
+ variant="flat"
67
+ color="primary"
68
+ size="small"
69
+ style="height: 40px"
70
+ prepend-icon="mdi-tray-arrow-up"
71
+ :loading="uploadingTemplate"
72
+ @click="triggerTemplateUpload"
73
+ >
74
+ Upload
75
+ </v-btn>
76
+ <v-btn
77
+ v-if="currentEntryPassSettings.template?.id"
78
+ variant="flat"
79
+ color="error"
80
+ size="small"
81
+ style="height: 40px"
82
+ prepend-icon="mdi-file-document-remove-outline"
83
+ :loading="uploadingTemplate"
84
+ @click="removeTemplate"
85
+ >
86
+ Remove
87
+ </v-btn>
88
+ </div>
89
+ <input
90
+ type="file"
91
+ ref="templateFileInput"
92
+ accept=".xlsx,.xls"
93
+ style="display: none"
94
+ @change="handleTemplateUpload"
95
+ />
71
96
  </div>
72
97
  <v-divider thickness="1"></v-divider>
73
98
  <div class="d-flex w-100 mt-7 pb-10">
74
- <p class="mr-6 font-weight-medium flex-grow-1">
99
+ <p class="font-weight-medium flex-grow-1">
75
100
  Printer Setup
76
101
  <v-col cols="12">
77
- <v-row>
102
+ <v-row align="center">
78
103
  <v-col cols="3">
79
104
  <v-text-field
80
105
  label="Vendor ID"
@@ -91,33 +116,39 @@
91
116
  v-model="currentEntryPassSettings.printerProductId"
92
117
  ></v-text-field>
93
118
  </v-col>
94
- <v-col cols="3">
119
+ <v-col cols="3" class="d-flex align-end">
95
120
  <v-btn
96
121
  color="primary"
97
122
  variant="outlined"
98
123
  prepend-icon="mdi-magnify"
99
124
  block
125
+ height="48"
126
+ :loading="scanningPrinter"
127
+ @click="scanPrinter()"
100
128
  >
101
129
  Scan Printer
102
130
  </v-btn>
103
131
  </v-col>
104
- <v-col cols="3">
132
+ <v-col cols="3" class="d-flex align-end pr-0">
105
133
  <v-btn
106
134
  color="success"
107
135
  variant="outlined"
108
136
  prepend-icon="mdi-printer-check"
109
137
  block
138
+ height="48"
139
+ :loading="testingPrinter"
140
+ @click="testAndPrint()"
110
141
  >
111
142
  Test & Print
112
143
  </v-btn>
113
144
  </v-col>
114
145
  </v-row>
115
146
  <v-row class="mt-4">
116
- <v-col cols="12" sm="6" md="4">
147
+ <v-col cols="12" md="3">
117
148
  <v-btn
118
149
  color="primary"
119
150
  variant="flat"
120
- prepend-icon="mdi-content-save"
151
+ prepend-icon="mdi-printer"
121
152
  block
122
153
  @click="savePrinterSettings()"
123
154
  >
@@ -132,22 +163,22 @@
132
163
  <v-divider thickness="1"></v-divider>
133
164
 
134
165
  <div class="d-flex w-100 mt-7 pb-10">
135
- <p class="mr-6 font-weight-medium flex-grow-1">
166
+ <p class="font-weight-medium flex-grow-1">
136
167
  QR Code Template
137
168
  <span class="d-block text-caption text-grey-darken-1 mt-1">
138
169
  <v-col cols="12">
139
170
  <v-row>
140
- <v-col cols="12">
171
+ <v-col cols="12" class="pr-0">
141
172
  <v-text-field
142
173
  label="Header"
143
- placeholder="Enter qr code header eg. Welcome to Company Name"
174
+ placeholder="Enter QR code header"
144
175
  hide-details
145
176
  density="comfortable"
146
177
  clearable
147
178
  v-model="currentEntryPassSettings.qrCodeTemplateHeader"
148
179
  ></v-text-field>
149
180
  </v-col>
150
- <v-col cols="12">
181
+ <v-col cols="12" class="pr-0">
151
182
  <v-text-field
152
183
  label="Subtext"
153
184
  placeholder="Enter qr code sub header"
@@ -161,15 +192,16 @@
161
192
  ></v-text-field>
162
193
  </v-col>
163
194
  <v-row class="mt-3">
164
- <v-col cols="12" md="2">
165
- <v-btn color="primary" variant="flat" block>
195
+ <v-col cols="12" md="3">
196
+ <v-btn color="success" variant="flat" prepend-icon="mdi-eye" block @click="isShowTemplatePreview = true">
166
197
  Preview
167
198
  </v-btn>
168
199
  </v-col>
169
- <v-col cols="12" md="2">
200
+ <v-col cols="12" md="3">
170
201
  <v-btn
171
202
  color="primary"
172
203
  variant="flat"
204
+ prepend-icon="mdi-qrcode"
173
205
  block
174
206
  @click="saveQrCodeTemplate()"
175
207
  >
@@ -186,10 +218,10 @@
186
218
  <v-divider thickness="1"></v-divider>
187
219
 
188
220
  <div class="d-flex w-100 mt-7 pb-10">
189
- <p class="mr-6 font-weight-medium flex-grow-1">
221
+ <p class="font-weight-medium flex-grow-1">
190
222
  Resident-app Disclaimer Message
191
223
  <span class="d-block text-caption text-grey-darken-1 mt-1">
192
- <v-col cols="12">
224
+ <v-col cols="12" class="pr-0">
193
225
  <v-row no-gutters>
194
226
  <v-col cols="12" class="mb-5">
195
227
  <v-textarea
@@ -204,10 +236,11 @@
204
236
  ></v-textarea>
205
237
  </v-col>
206
238
  <v-row class="mt-3">
207
- <v-col cols="12" md="2">
239
+ <v-col cols="12" md="3">
208
240
  <v-btn
209
241
  color="primary"
210
242
  variant="flat"
243
+ prepend-icon="mdi-message-text-outline"
211
244
  block
212
245
  @click="saveResidentAppDisclaimerMsg()"
213
246
  >
@@ -224,21 +257,21 @@
224
257
  <v-divider thickness="1"></v-divider>
225
258
 
226
259
  <div class="d-flex w-100 mt-7 pb-10">
227
- <p class="mr-6 font-weight-medium flex-grow-1">
260
+ <p class="font-weight-medium flex-grow-1">
228
261
  Entrypass URL
229
262
  <span class="d-block text-caption text-grey-darken-1 mt-1">
230
- <v-col>
263
+ <v-col class="pr-0">
231
264
  <v-text-field
232
265
  label="Enter entrypass URL"
233
- placeholder="https://example.com"
266
+ placeholder="https://your-entrypass-socket-url.com"
234
267
  outlined
235
268
  clearable
236
269
  hide-details
237
270
  v-model="currentEntryPassSettings.url"
238
271
  />
239
272
  </v-col>
240
- <v-col>
241
- <v-btn color="primary" @click="saveEntryPassUrl()">Save</v-btn>
273
+ <v-col cols="12" md="3">
274
+ <v-btn color="primary" variant="flat" prepend-icon="mdi-link-variant" block @click="saveEntryPassUrl()">Save</v-btn>
242
275
  </v-col>
243
276
  </span>
244
277
  </p>
@@ -247,6 +280,12 @@
247
280
  </v-col>
248
281
 
249
282
  <Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
283
+
284
+ <EntryPassQrTemplatePreview
285
+ v-model="isShowTemplatePreview"
286
+ :header="currentEntryPassSettings.qrCodeTemplateHeader"
287
+ :sub-text="currentEntryPassSettings.qrCodeTemplateHeaderSubText"
288
+ />
250
289
  </v-row>
251
290
  </template>
252
291
  <script lang="ts" setup>
@@ -275,8 +314,13 @@ const currentEntryPassSettings = ref<Record<string, any>>({
275
314
  site: "",
276
315
  org: "",
277
316
  isEnabled: true,
317
+ api: null,
318
+ port: null,
319
+ serviceId: null,
278
320
  physicalPass: false,
279
321
  nfcPass: false,
322
+ qrPass: false,
323
+ keyPass: false,
280
324
  printerVendorId: "",
281
325
  printerProductId: "",
282
326
  qrCodeTemplateHeader: "",
@@ -284,6 +328,7 @@ const currentEntryPassSettings = ref<Record<string, any>>({
284
328
  qrCodeTemplateDate: "",
285
329
  disclaimerMessage: "",
286
330
  url: "",
331
+ template: { id: "", name: "" },
287
332
  status: "",
288
333
  createdBy: "",
289
334
  updatedBy: "",
@@ -292,28 +337,118 @@ const currentEntryPassSettings = ref<Record<string, any>>({
292
337
  deletedAt: "",
293
338
  });
294
339
 
295
- const entryPassSettingsPayload = ref<Record<string, any>>({
296
- site: "",
297
- org: "",
298
- isEnabled: true,
299
- physicalPass: false,
300
- nfcPass: false,
301
- printerVendorId: "",
302
- printerProductId: "",
303
- qrCodeTemplateHeader: "",
304
- qrCodeTemplateHeaderSubText: "",
305
- qrCodeTemplateDate: "",
306
- disclaimerMessage: "",
307
- url: "",
308
- status: "",
309
- });
310
-
311
340
  const {
312
341
  getBySiteId: _getSiteEntryPassSettings,
313
- add: _add,
314
- updateBySiteId: _updateBySiteId,
342
+ save: _save,
315
343
  } = useSiteEntryPassSettings();
316
344
 
345
+ const { requestDevice, testConnection, isWebUsbSupported } = useWebUsb();
346
+ const { addFile, getFileUrl } = useFile();
347
+
348
+ const scanningPrinter = ref(false);
349
+ const testingPrinter = ref(false);
350
+ const isShowTemplatePreview = ref(false);
351
+ const uploadingTemplate = ref(false);
352
+ const templateFileInput = ref<HTMLInputElement | null>(null);
353
+
354
+ function triggerTemplateUpload() {
355
+ templateFileInput.value?.click();
356
+ }
357
+
358
+ async function handleTemplateUpload(e: Event) {
359
+ const files = (e.target as HTMLInputElement).files;
360
+ if (!files || files.length === 0) return;
361
+ uploadingTemplate.value = true;
362
+ try {
363
+ const res = await addFile(files[0]);
364
+ currentEntryPassSettings.value.template = {
365
+ id: res.id as string,
366
+ name: (res.name as string) || files[0].name,
367
+ };
368
+ await _save(buildPayload());
369
+ showMessage("Template uploaded successfully!", "success");
370
+ getSiteEntryPassSettings();
371
+ } catch {
372
+ showMessage("Failed to upload template", "error");
373
+ } finally {
374
+ uploadingTemplate.value = false;
375
+ (e.target as HTMLInputElement).value = "";
376
+ }
377
+ }
378
+
379
+ async function removeTemplate() {
380
+ currentEntryPassSettings.value.template = { id: "", name: "" };
381
+ await _save(buildPayload());
382
+ showMessage("Template removed successfully!", "success");
383
+ getSiteEntryPassSettings();
384
+ }
385
+
386
+ async function downloadTemplate() {
387
+ const { id, name } = currentEntryPassSettings.value.template;
388
+ try {
389
+ const response = await fetch(getFileUrl(id));
390
+ const blob = await response.blob();
391
+ const blobUrl = URL.createObjectURL(blob);
392
+ const link = document.createElement("a");
393
+ link.href = blobUrl;
394
+ link.download = name;
395
+ document.body.appendChild(link);
396
+ link.click();
397
+ document.body.removeChild(link);
398
+ URL.revokeObjectURL(blobUrl);
399
+ } catch {
400
+ showMessage("Failed to download template", "error");
401
+ }
402
+ }
403
+
404
+ async function scanPrinter() {
405
+ if (!isWebUsbSupported.value) {
406
+ showMessage("Web USB is not supported in this browser", "error");
407
+ return;
408
+ }
409
+ try {
410
+ scanningPrinter.value = true;
411
+ const device = await requestDevice();
412
+ currentEntryPassSettings.value.printerVendorId = String(device.vendorId);
413
+ currentEntryPassSettings.value.printerProductId = String(device.productId);
414
+ showMessage(
415
+ `Printer found: ${device.productName} (${device.vendorId}:${device.productId})`,
416
+ "success",
417
+ );
418
+ } catch (error: any) {
419
+ if (error.message !== "No device selected") {
420
+ showMessage(error.message || "Failed to scan printer", "error");
421
+ }
422
+ } finally {
423
+ scanningPrinter.value = false;
424
+ }
425
+ }
426
+
427
+ async function testAndPrint() {
428
+ if (!isWebUsbSupported.value) {
429
+ showMessage("Web USB is not supported in this browser", "error");
430
+ return;
431
+ }
432
+ const vendorId = Number(currentEntryPassSettings.value.printerVendorId);
433
+ const productId = Number(currentEntryPassSettings.value.printerProductId);
434
+ if (!vendorId || !productId) {
435
+ showMessage("Please set a valid Vendor ID and Product ID first", "warning");
436
+ return;
437
+ }
438
+ try {
439
+ testingPrinter.value = true;
440
+ const result = await testConnection(vendorId, productId);
441
+ showMessage(
442
+ result.message,
443
+ result.success ? "success" : "error",
444
+ );
445
+ } catch (error: any) {
446
+ showMessage(error.message || "Test print failed", "error");
447
+ } finally {
448
+ testingPrinter.value = false;
449
+ }
450
+ }
451
+
317
452
  const route = useRoute();
318
453
  const siteId = route.params.site as string;
319
454
  const orgId = route.params.org as string;
@@ -335,178 +470,95 @@ const loading = computed(
335
470
  );
336
471
 
337
472
  watchEffect(() => {
338
- if (getSiteEntryPassSettingsReq.value) {
339
- currentEntryPassSettings.value = getSiteEntryPassSettingsReq.value;
340
- // console.log("currentEntryPassSettings", currentEntryPassSettings.value);
341
- // console.log(currentEntryPassSettings.value._id);
473
+ const data = getSiteEntryPassSettingsReq.value?.data;
474
+ if (data) {
475
+ currentEntryPassSettings.value = {
476
+ ...currentEntryPassSettings.value,
477
+ _id: data._id ?? "",
478
+ site: data.site ?? "",
479
+ isEnabled: data.isEnabled ?? true,
480
+ api: data.api ?? null,
481
+ port: data.port ?? null,
482
+ serviceId: data.serviceId ?? null,
483
+ physicalPass: data.settings?.physicalPass ?? false,
484
+ nfcPass: data.settings?.nfcPass ?? false,
485
+ qrPass: data.settings?.qrPass ?? false,
486
+ keyPass: data.settings?.keyPass ?? false,
487
+ printerVendorId: data.settings?.printer?.vendorId ? String(data.settings.printer.vendorId) : "",
488
+ printerProductId: data.settings?.printer?.productId ? String(data.settings.printer.productId) : "",
489
+ qrCodeTemplateHeader: data.settings?.qrTemplate?.header ?? "",
490
+ qrCodeTemplateHeaderSubText: data.settings?.qrTemplate?.subText ?? "",
491
+ qrCodeTemplateDate: data.settings?.qrTemplate?.date ?? "",
492
+ url: data.settings?.url ?? "",
493
+ template: data.settings?.template ?? { id: "", name: "" },
494
+ createdAt: data.createdAt ?? "",
495
+ updatedAt: data.updatedAt ?? "",
496
+ };
342
497
  }
343
498
  });
344
499
 
345
- async function addPayload() {
346
- const payload = {
500
+ function buildPayload() {
501
+ return {
347
502
  site: siteId,
348
- org: orgId,
349
- isEnabled: true,
350
- physicalPass: currentEntryPassSettings.value.physicalPass,
351
- nfcPass: currentEntryPassSettings.value.nfcPass,
352
- printerVendorId: currentEntryPassSettings.value.printerVendorId,
353
- printerProductId: currentEntryPassSettings.value.printerProductId,
354
- qrCodeTemplateHeader: currentEntryPassSettings.value.qrCodeTemplateHeader,
355
- qrCodeTemplateHeaderSubText:
356
- currentEntryPassSettings.value.qrCodeTemplateHeaderSubText,
357
- qrCodeTemplateDate: currentEntryPassSettings.value.qrCodeTemplateDate,
358
- disclaimerMessage: currentEntryPassSettings.value.disclaimerMessage,
359
- url: currentEntryPassSettings.value.url,
360
- status: "Active",
503
+ isEnabled: currentEntryPassSettings.value.isEnabled ?? true,
504
+ api: currentEntryPassSettings.value.api ?? null,
505
+ port: currentEntryPassSettings.value.port ?? null,
506
+ serviceId: currentEntryPassSettings.value.serviceId ?? null,
507
+ settings: {
508
+ physicalPass: currentEntryPassSettings.value.physicalPass,
509
+ nfcPass: currentEntryPassSettings.value.nfcPass,
510
+ qrPass: currentEntryPassSettings.value.qrPass ?? false,
511
+ keyPass: currentEntryPassSettings.value.keyPass ?? false,
512
+ printer: {
513
+ vendorId: Number(currentEntryPassSettings.value.printerVendorId) || null,
514
+ productId: Number(currentEntryPassSettings.value.printerProductId) || null,
515
+ },
516
+ qrTemplate: {
517
+ header: currentEntryPassSettings.value.qrCodeTemplateHeader,
518
+ subText: currentEntryPassSettings.value.qrCodeTemplateHeaderSubText,
519
+ date: currentEntryPassSettings.value.qrCodeTemplateDate || null,
520
+ },
521
+ url: currentEntryPassSettings.value.url,
522
+ template: currentEntryPassSettings.value.template?.id
523
+ ? currentEntryPassSettings.value.template
524
+ : null,
525
+ },
361
526
  };
362
- entryPassSettingsPayload.value = payload;
363
- }
364
-
365
- async function updatePayload() {
366
- const payload = {
367
- isEnabled: true,
368
- physicalPass: currentEntryPassSettings.value.physicalPass,
369
- nfcPass: currentEntryPassSettings.value.nfcPass,
370
- printerVendorId: currentEntryPassSettings.value.printerVendorId,
371
- printerProductId: currentEntryPassSettings.value.printerProductId,
372
- qrCodeTemplateHeader: currentEntryPassSettings.value.qrCodeTemplateHeader,
373
- qrCodeTemplateHeaderSubText:
374
- currentEntryPassSettings.value.qrCodeTemplateHeaderSubText,
375
- qrCodeTemplateDate: currentEntryPassSettings.value.qrCodeTemplateDate,
376
- disclaimerMessage: currentEntryPassSettings.value.disclaimerMessage,
377
- url: currentEntryPassSettings.value.url,
378
- status: "Active",
379
- };
380
- entryPassSettingsPayload.value = payload;
381
527
  }
382
528
 
383
529
  async function updateEntryPassSettingsPhysicalPass() {
384
- if (!currentEntryPassSettings.value._id) {
385
- addPayload();
386
- entryPassSettingsPayload.value.physicalPass =
387
- currentEntryPassSettings.value.physicalPass;
388
- await _add(entryPassSettingsPayload.value);
389
- showMessage("Entry Pass Settings added successfully!", "success");
390
- } else {
391
- updatePayload();
392
- entryPassSettingsPayload.value.physicalPass =
393
- currentEntryPassSettings.value.physicalPass;
394
- await _updateBySiteId(
395
- entryPassSettingsPayload.value,
396
- currentEntryPassSettings.value.site
397
- );
398
- showMessage("Entry Pass Settings updated successfully!", "success");
399
- }
530
+ await _save(buildPayload());
531
+ showMessage("Entry Pass Settings updated successfully!", "success");
400
532
  getSiteEntryPassSettings();
401
533
  }
402
534
 
403
535
  async function updateEntryPassSettingsNfcPass() {
404
- if (!currentEntryPassSettings.value._id) {
405
- addPayload();
406
- entryPassSettingsPayload.value.nfcPass =
407
- currentEntryPassSettings.value.nfcPass;
408
- await _add(entryPassSettingsPayload.value);
409
- showMessage("Entry Pass Settings added successfully!", "success");
410
- } else {
411
- updatePayload();
412
- entryPassSettingsPayload.value.nfcPass =
413
- currentEntryPassSettings.value.nfcPass;
414
- await _updateBySiteId(
415
- entryPassSettingsPayload.value,
416
- currentEntryPassSettings.value.site
417
- );
418
- showMessage("Entry Pass Settings updated successfully!", "success");
419
- }
536
+ await _save(buildPayload());
537
+ showMessage("Entry Pass Settings updated successfully!", "success");
420
538
  getSiteEntryPassSettings();
421
539
  }
422
540
 
423
541
  async function savePrinterSettings() {
424
- if (!currentEntryPassSettings.value._id) {
425
- addPayload();
426
- entryPassSettingsPayload.value.printerVendorId =
427
- currentEntryPassSettings.value.printerVendorId;
428
- entryPassSettingsPayload.value.printerProductId =
429
- currentEntryPassSettings.value.printerProductId;
430
- await _add(entryPassSettingsPayload.value);
431
- showMessage("Entry Pass Settings added successfully!", "success");
432
- } else {
433
- updatePayload();
434
- entryPassSettingsPayload.value.printerVendorId =
435
- currentEntryPassSettings.value.printerVendorId;
436
- entryPassSettingsPayload.value.printerProductId =
437
- currentEntryPassSettings.value.printerProductId;
438
- console.log(
439
- "entryPassSettingsPayload.value",
440
- entryPassSettingsPayload.value
441
- );
442
- await _updateBySiteId(
443
- entryPassSettingsPayload.value,
444
- currentEntryPassSettings.value.site
445
- );
446
- showMessage("Entry Pass Settings updated successfully!", "success");
447
- }
542
+ await _save(buildPayload());
543
+ showMessage("Entry Pass Settings updated successfully!", "success");
448
544
  getSiteEntryPassSettings();
449
545
  }
450
546
 
451
547
  async function saveQrCodeTemplate() {
452
- if (!currentEntryPassSettings.value._id) {
453
- addPayload();
454
- entryPassSettingsPayload.value.qrCodeTemplateHeader =
455
- currentEntryPassSettings.value.qrCodeTemplateHeader;
456
- entryPassSettingsPayload.value.qrCodeTemplateHeaderSubText =
457
- currentEntryPassSettings.value.qrCodeTemplateHeaderSubText;
458
- await _add(entryPassSettingsPayload.value);
459
- showMessage("Entry Pass Settings added successfully!", "success");
460
- } else {
461
- updatePayload();
462
- entryPassSettingsPayload.value.qrCodeTemplateHeader =
463
- currentEntryPassSettings.value.qrCodeTemplateHeader;
464
- entryPassSettingsPayload.value.qrCodeTemplateHeaderSubText =
465
- currentEntryPassSettings.value.qrCodeTemplateHeaderSubText;
466
- await _updateBySiteId(
467
- entryPassSettingsPayload.value,
468
- currentEntryPassSettings.value.site
469
- );
470
- showMessage("Entry Pass Settings updated successfully!", "success");
471
- }
548
+ await _save(buildPayload());
549
+ showMessage("Entry Pass Settings updated successfully!", "success");
472
550
  getSiteEntryPassSettings();
473
551
  }
474
552
 
475
553
  async function saveResidentAppDisclaimerMsg() {
476
- if (!currentEntryPassSettings.value._id) {
477
- addPayload();
478
- entryPassSettingsPayload.value.disclaimerMessage =
479
- currentEntryPassSettings.value.disclaimerMessage;
480
- await _add(entryPassSettingsPayload.value);
481
- showMessage("Entry Pass Settings added successfully!", "success");
482
- } else {
483
- updatePayload();
484
- entryPassSettingsPayload.value.disclaimerMessage =
485
- currentEntryPassSettings.value.disclaimerMessage;
486
- await _updateBySiteId(
487
- entryPassSettingsPayload.value,
488
- currentEntryPassSettings.value.site
489
- );
490
- showMessage("Entry Pass Settings updated successfully!", "success");
491
- }
554
+ await _save(buildPayload());
555
+ showMessage("Entry Pass Settings updated successfully!", "success");
492
556
  getSiteEntryPassSettings();
493
557
  }
494
558
 
495
559
  async function saveEntryPassUrl() {
496
- if (!currentEntryPassSettings.value._id) {
497
- addPayload();
498
- entryPassSettingsPayload.value.url = currentEntryPassSettings.value.url;
499
- await _add(entryPassSettingsPayload.value);
500
- showMessage("Entry Pass Settings added successfully!", "success");
501
- } else {
502
- updatePayload();
503
- entryPassSettingsPayload.value.url = currentEntryPassSettings.value.url;
504
- await _updateBySiteId(
505
- entryPassSettingsPayload.value,
506
- currentEntryPassSettings.value.site
507
- );
508
- showMessage("Entry Pass Settings updated successfully!", "success");
509
- }
560
+ await _save(buildPayload());
561
+ showMessage("Entry Pass Settings updated successfully!", "success");
510
562
  getSiteEntryPassSettings();
511
563
  }
512
564