@7365admin1/layer-common 3.0.27 → 3.0.29

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.
@@ -579,6 +579,7 @@
579
579
  :visitor-data="selectedVisitorDataObject"
580
580
  :current-user="currentUser._id"
581
581
  :type="activeVisitorFormType"
582
+ :enable-unregistered="enableUnregistered"
582
583
  @back="handleClickBack"
583
584
  @done="handleVisitorFormDone"
584
585
  @done:more="handleVisitorFormCreateMore"
@@ -1824,7 +1825,7 @@ const nfcCardReturnStatuses = ref<
1824
1825
  const canConfirmCheckout = computed(() => {
1825
1826
  const allEntries = [...passReturnStatuses.value, ...keyReturnStatuses.value];
1826
1827
  return allEntries.every((entry) => {
1827
- if (!entry.status || entry.status === "In Use") return false;
1828
+ if (!entry.status || ["In Use","Not Returned"].includes(entry.status)) return false;
1828
1829
  if (
1829
1830
  (entry.status === "Lost" || entry.status === "Damaged") &&
1830
1831
  !entry.remarks.trim()
@@ -2190,29 +2191,60 @@ watch([searchInput, dateFrom, dateTo, filterTypes, activeTab], () => {
2190
2191
  page.value = 1;
2191
2192
  });
2192
2193
 
2193
- onMounted(() => {
2194
+ const syncVisitorFiltersFromRoute = () => {
2194
2195
  const requestedTab = (route.query.tab as string) || "registered";
2195
- activeTab.value = enableUnregisteredTab.value
2196
+ const nextTab = enableUnregisteredTab.value
2196
2197
  ? requestedTab
2197
2198
  : requestedTab === "unregistered"
2198
2199
  ? "registered"
2199
2200
  : requestedTab;
2200
- searchInput.value = (route.query.search as string) || "";
2201
+
2202
+ if (activeTab.value !== nextTab) {
2203
+ activeTab.value = nextTab;
2204
+ }
2205
+
2206
+ const nextSearch = (route.query.search as string) || "";
2207
+ if (searchInput.value !== nextSearch) {
2208
+ searchInput.value = nextSearch;
2209
+ }
2210
+
2201
2211
  if (route.query.dateFrom) {
2202
- dateFrom.value = normalizeDateOnly(route.query.dateFrom as string);
2212
+ const nextDateFrom = normalizeDateOnly(route.query.dateFrom as string);
2213
+ if (dateFrom.value !== nextDateFrom) {
2214
+ dateFrom.value = nextDateFrom;
2215
+ }
2203
2216
  }
2217
+
2204
2218
  if (route.query.dateTo) {
2205
- dateTo.value = normalizeDateOnly(route.query.dateTo as string);
2219
+ const nextDateTo = normalizeDateOnly(route.query.dateTo as string);
2220
+ if (dateTo.value !== nextDateTo) {
2221
+ dateTo.value = nextDateTo;
2222
+ }
2206
2223
  }
2224
+
2207
2225
  if (activeTab.value === "registered") {
2208
- filterTypes.value = ((route.query.type as string)?.split(",") || []).filter(
2209
- Boolean
2210
- ) as TVisitorType[];
2226
+ const nextFilterTypes = (
2227
+ (route.query.type as string)?.split(",") || []
2228
+ ).filter(Boolean) as TVisitorType[];
2229
+ if (filterTypes.value.join(",") !== nextFilterTypes.join(",")) {
2230
+ filterTypes.value = nextFilterTypes;
2231
+ }
2211
2232
 
2212
- displayNotCheckedOut.value =
2233
+ const nextDisplayNotCheckedOut =
2213
2234
  (route.query.checkedOut as string) == "true" || false;
2235
+ if (displayNotCheckedOut.value !== nextDisplayNotCheckedOut) {
2236
+ displayNotCheckedOut.value = nextDisplayNotCheckedOut;
2237
+ }
2214
2238
  }
2215
- });
2239
+ };
2240
+
2241
+ onMounted(syncVisitorFiltersFromRoute);
2242
+
2243
+ watch(
2244
+ () => route.query,
2245
+ syncVisitorFiltersFromRoute,
2246
+ { deep: true }
2247
+ );
2216
2248
 
2217
2249
  const { socketUnregisteredVisitorTrigger, visitorSocketData } =
2218
2250
  useVisitorSocket();
@@ -314,7 +314,7 @@ export default function useAccessManagement() {
314
314
  );
315
315
  }
316
316
 
317
- function assignUser(payload: { assignees: string[]; unit: string; type: string; acm_url: string }) {
317
+ function assignUser(payload: { assignees: string[]; unit: string; type: string; acm_url: string; id?: string }) {
318
318
  return useNuxtApp().$api<Record<string, any>>(
319
319
  `/api/access-management/assign-user`,
320
320
  { method: "POST", body: payload }
@@ -94,6 +94,25 @@ export default function () {
94
94
  tab?: string;
95
95
  };
96
96
 
97
+ type SearchUncheckedOutUnregisteredVisitorParams = {
98
+ site: string;
99
+ plateNumber: string;
100
+ hourAgo?: number;
101
+ page?: number;
102
+ limit?: number;
103
+ };
104
+
105
+ type SearchVisitorObjectParams = {
106
+ page?: number;
107
+ limit?: number;
108
+ site: string;
109
+ searchObject: {
110
+ nric?: string | null;
111
+ contact?: string | null;
112
+ };
113
+ notCheckedOut?: boolean;
114
+ };
115
+
97
116
  const tab = useState("visitorsTab", () => "visitor");
98
117
 
99
118
  async function getVisitors({
@@ -159,6 +178,48 @@ export default function () {
159
178
  );
160
179
  }
161
180
 
181
+ async function checkSearchUncheckedOutUnregisteredVisitor({
182
+ site,
183
+ plateNumber,
184
+ hourAgo = 24,
185
+ page = 1,
186
+ limit = 100,
187
+ }: SearchUncheckedOutUnregisteredVisitorParams) {
188
+ return await useNuxtApp().$api<Record<string, any>>("/api/visitors", {
189
+ method: "GET",
190
+ query: {
191
+ site,
192
+ type: "uncheckout-unregistered",
193
+ plateNumber,
194
+ hourAgo,
195
+ page,
196
+ limit,
197
+ },
198
+ });
199
+ }
200
+
201
+ async function searchVisitorObject({
202
+ page = 1,
203
+ limit = 1000,
204
+ site,
205
+ searchObject,
206
+ notCheckedOut = true,
207
+ }: SearchVisitorObjectParams) {
208
+ return await useNuxtApp().$api<Record<string, any>>(
209
+ "/api/visitors/search-object",
210
+ {
211
+ method: "POST",
212
+ body: {
213
+ page,
214
+ limit,
215
+ site,
216
+ searchObject,
217
+ notCheckedOut,
218
+ },
219
+ }
220
+ );
221
+ }
222
+
162
223
  async function deleteVisitor(_id: string) {
163
224
  return await useNuxtApp().$api<Record<string, any>>(
164
225
  `/api/visitor-transactions/id/${_id}`,
@@ -198,6 +259,8 @@ export default function () {
198
259
  contractorTypes,
199
260
  createVisitor,
200
261
  getVisitors,
262
+ checkSearchUncheckedOutUnregisteredVisitor,
263
+ searchVisitorObject,
201
264
  updateVisitor,
202
265
  deleteVisitor,
203
266
  validateVisitorQrCode,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "3.0.27",
5
+ "version": "3.0.29",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {