@7365admin1/layer-common 3.2.4 → 3.2.6

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.
@@ -52,7 +52,7 @@
52
52
  <v-col cols="12" class="d-flex align-center">
53
53
  <v-autocomplete
54
54
  :items="
55
- localTemplateList.filter(
55
+ templateOptions.filter(
56
56
  (item) => !['All', 'Manually Added'].includes(item.name)
57
57
  )
58
58
  "
@@ -238,7 +238,7 @@
238
238
  >
239
239
  <v-autocomplete
240
240
  label="Start"
241
- :items="resultKeys2"
241
+ :items="passRangeOptions"
242
242
  item-title="text"
243
243
  item-value="value"
244
244
  v-model="startRange"
@@ -319,7 +319,7 @@
319
319
  <v-row no-gutters dense>
320
320
  <v-col cols="12">
321
321
  <v-data-iterator
322
- :items="resultKeys2?.items"
322
+ :items="keyListResult?.items || []"
323
323
  :items-per-page="selectedPageRange"
324
324
  >
325
325
  <template v-slot:header>
@@ -697,7 +697,7 @@
697
697
  </v-col>
698
698
 
699
699
  <v-col cols="3" class="text-end">
700
- <span>{{ resultKeys2?.pageRange }}</span>
700
+ <span>{{ keyListResult?.pageRange }}</span>
701
701
  <v-btn
702
702
  density="compact"
703
703
  variant="text"
@@ -731,14 +731,7 @@
731
731
  <v-btn
732
732
  color="primary"
733
733
  @click="printContent"
734
- :disabled="
735
- tab !== 'key'
736
- ? !selectedChoicePaperSizeOrientation ||
737
- !selectedTemplate?._id ||
738
- !startRange ||
739
- !endRange
740
- : !selectedKeysToPrint.length
741
- "
734
+ :disabled="isPrintDisabled"
742
735
  >
743
736
  Print
744
737
  </v-btn>
@@ -780,6 +773,18 @@
780
773
  </template>
781
774
 
782
775
  <script setup lang="ts">
776
+ type TemplateOption = {
777
+ _id?: string | null;
778
+ name: string;
779
+ prefixPass?: string;
780
+ prefixKey?: string;
781
+ };
782
+
783
+ type PassRangeOption = {
784
+ text: string;
785
+ value: string;
786
+ };
787
+
783
788
  const { templateQrCode, getTemplatesByPageSearch } = useTemplateReusable();
784
789
 
785
790
  const {
@@ -794,7 +799,7 @@ const {
794
799
 
795
800
  const props = defineProps<{
796
801
  open: Boolean;
797
- templateList: Array;
802
+ templateList: Array<TemplateOption>;
798
803
  template: any;
799
804
  type: any;
800
805
  orientation: any;
@@ -802,90 +807,147 @@ const props = defineProps<{
802
807
  }>();
803
808
 
804
809
  const route = useRoute();
805
-
810
+ const router = useRouter();
806
811
  const emit = defineEmits(["update:close"]);
807
812
 
808
813
  const selectedChoicePaperSizeOrientation = ref<any>(null);
809
-
810
- const resultKeys2 = ref<any>([]);
814
+ const passRangeOptions = ref<PassRangeOption[]>([]);
811
815
  const startRange = ref<any>(null);
812
816
  const endRange = ref<any>(null);
813
817
  const prefixAndName = ref<string>("");
814
818
 
815
819
  const snackbarStartRange = ref<boolean>(false);
816
-
817
820
  const isFetchingTemplates = ref<boolean>(false);
818
821
  const isFetchingPassKeys = ref<boolean>(false);
819
-
820
822
  const resultPass = ref<any>(null);
821
823
 
822
824
  const searchKey = ref("");
823
825
  const totalPages = ref(0);
826
+ const page = ref(1);
824
827
  const canNextPage = computed(() => totalPages.value > page.value);
825
828
  const canPrevPage = computed(() => page.value <= 1);
826
829
  const pageRanges = ref([10, 25, 50, 100, 500, 1000]);
827
830
  const selectedPageRange = ref(10);
828
831
 
829
832
  const selectAll = ref(false);
830
- const localTemplateList = ref([]);
833
+ const templateOptions = ref<TemplateOption[]>([]);
834
+ const keyListResult = ref<any>({
835
+ items: [],
836
+ pages: 0,
837
+ pageRange: "-- - -- of --",
838
+ });
839
+ const message = ref("");
840
+ const messageColor = ref("");
841
+ const messageSnackbar = ref(false);
842
+
843
+ const isPassTab = computed(() => tab.value === "pass");
844
+ const isKeyTab = computed(() => tab.value === "key");
845
+ const selectedTemplateId = computed(
846
+ () => selectedTemplate.value?._id ?? props.template?._id ?? null
847
+ );
848
+ const isPrintDisabled = computed(() =>
849
+ isKeyTab.value
850
+ ? !selectedKeysToPrint.value.length
851
+ : !selectedChoicePaperSizeOrientation.value ||
852
+ !selectedTemplateId.value ||
853
+ !startRange.value ||
854
+ !endRange.value
855
+ );
831
856
 
832
857
  watch(
833
858
  () => props.templateList,
834
859
  (newVal) => {
835
- localTemplateList.value = newVal;
836
- }
860
+ templateOptions.value = Array.isArray(newVal)
861
+ ? newVal.map((item) => ({
862
+ _id: item?._id ?? null,
863
+ name: item?.name ?? "",
864
+ prefixPass: item?.prefixPass,
865
+ prefixKey: item?.prefixKey,
866
+ }))
867
+ : [];
868
+ },
869
+ { immediate: true }
837
870
  );
838
871
 
839
- // interset start
840
-
841
- // const page = ref(1); // replace with your actual page value
842
- // const totalNumberOfPagesTemplateList = ref(1); // replace with your actual total number of pages value
843
-
844
- // const endIntersectTemplateList = async (isIntersecting) => {
845
- // await getTemplateNameLists(page.value);
846
- // if (isIntersecting && !isFetchingTemplates.value) {
847
- // page.value += 1;
848
- // await getTemplateNameLists(page.value);
849
- // }
850
- // };
851
-
852
- // const getTemplateNameLists = async (page = 1, query = "") => {
853
- // isFetchingTemplates.value = true;
854
-
855
- // const result = await getTemplatesByPageSearch({
856
- // sites: [route.params.site as string],
857
- // limit: 10,
858
- // page: page,
859
- // statuses: ["active"],
860
- // search: query,
861
- // });
862
-
863
- // totalNumberOfPagesTemplateList.value = result?.pages;
864
- // if (result?.items.length) {
865
- // const newItems = result?.items.map((item) => ({
866
- // _id: item._id,
867
- // name: item.name,
868
- // prefixPass: item.prefixPass,
869
- // prefixKey: item.prefixKey,
870
- // }));
871
-
872
- // if (page === 1) {
873
- // newItems.unshift({ _id: null, name: "All" });
874
- // newItems.push({ _id: "Manually Added", name: "Manually Added" });
875
- // }
876
-
877
- // // Only add new items if they don't already exist in the list
878
- // newItems.forEach((newItem) => {
879
- // if (!localTemplateList.value.find((item) => item._id === newItem._id)) {
880
- // localTemplateList.value.push(newItem);
881
- // }
882
- // });
883
- // }
884
-
885
- // isFetchingTemplates.value = false;
886
- // };
887
-
888
- const searchTemplate = async (query) => {
872
+ function resetPrintState() {
873
+ selectedChoicePaperSizeOrientation.value = null;
874
+ passRangeOptions.value = [];
875
+ startRange.value = null;
876
+ endRange.value = null;
877
+ prefixAndName.value = "";
878
+ selectAll.value = false;
879
+ keyListResult.value = {
880
+ items: [],
881
+ pages: 0,
882
+ pageRange: "-- - -- of --",
883
+ };
884
+ }
885
+
886
+ function getTemplateOptionItems(items: Array<any> = []) {
887
+ return items.map((item) => ({
888
+ _id: item?._id ?? null,
889
+ name: item?.name ?? "",
890
+ prefixPass: item?.prefixPass,
891
+ prefixKey: item?.prefixKey,
892
+ }));
893
+ }
894
+
895
+ function mapPassRangeItems(items: Array<any> = []) {
896
+ return items
897
+ .map((item: any) => ({
898
+ text: item?.prefixAndName ?? item?.name ?? "N/A",
899
+ value: item?.name ?? "",
900
+ }))
901
+ .filter((item) => item.value)
902
+ .sort((firstItem, secondItem) => {
903
+ const numericValueOfFirstItem = Number(
904
+ firstItem.value.replace(/\D/g, "")
905
+ );
906
+ const numericValueOfSecondItem = Number(
907
+ secondItem.value.replace(/\D/g, "")
908
+ );
909
+
910
+ return numericValueOfFirstItem - numericValueOfSecondItem;
911
+ });
912
+ }
913
+
914
+ function normalizePassNumberValue(value: string | null | undefined) {
915
+ const rawValue = (value ?? "").toString().trim();
916
+ if (!rawValue) return "";
917
+
918
+ const match = rawValue.match(/^(.*?)(\d+)$/);
919
+ if (!match) return rawValue;
920
+
921
+ const prefix = match[1].replace(/\s+/g, "").toUpperCase();
922
+ const numericPart = match[2];
923
+
924
+ return `${prefix}${numericPart}`;
925
+ }
926
+
927
+ function getPassNumberPrefix(value: string | null | undefined) {
928
+ const normalizedValue = normalizePassNumberValue(value);
929
+
930
+ return normalizedValue.replace(/\d+$/, "").replace(/\s+/g, "").toUpperCase();
931
+ }
932
+
933
+ function syncPrefixFromSelection() {
934
+ const selectedRangeOption = passRangeOptions.value.find(
935
+ (item) => item.value === startRange.value
936
+ );
937
+ const fallbackOption = selectedRangeOption ?? passRangeOptions.value[0];
938
+
939
+ prefixAndName.value = getPassNumberPrefix(
940
+ fallbackOption?.text ?? fallbackOption?.value ?? ""
941
+ );
942
+ }
943
+
944
+ function showMessage(msg: string, color: string) {
945
+ message.value = msg;
946
+ messageColor.value = color;
947
+ messageSnackbar.value = true;
948
+ }
949
+
950
+ const searchTemplate = async (query: string) => {
889
951
  isFetchingTemplates.value = true;
890
952
 
891
953
  const result = await getTemplatesByPageSearch({
@@ -896,34 +958,25 @@ const searchTemplate = async (query) => {
896
958
  search: query,
897
959
  });
898
960
 
899
- if (result?.items.length) {
900
- props.templateList = result?.items.map((item) => ({
901
- _id: item._id,
902
- name: item.name,
903
- prefixPass: item.prefixPass,
904
- prefixKey: item.prefixKey,
905
- }));
906
-
907
- props.templateList.unshift({ _id: null, name: "All" });
908
- props.templateList.push({ _id: "Manually Added", name: "Manually Added" });
909
- }
961
+ templateOptions.value = getTemplateOptionItems(result?.items ?? []);
962
+ templateOptions.value.unshift({ _id: null, name: "All" });
963
+ templateOptions.value.push({ _id: "Manually Added", name: "Manually Added" });
910
964
 
911
965
  isFetchingTemplates.value = false;
912
966
  };
913
- //end intersect
914
967
 
915
968
  async function selectAllKeys() {
916
969
  if (selectAll.value) {
917
- selectedKeysToPrint.value = resultKeys2.value?.items;
970
+ selectedKeysToPrint.value = keyListResult.value?.items ?? [];
918
971
  } else {
919
972
  selectedKeysToPrint.value = [];
920
973
  }
921
974
  }
922
975
 
923
- const closeDialog = async (type?: string, tab?: string) => {
976
+ const closeDialog = async (type?: string, tabType?: string) => {
924
977
  await emit("update:close", false);
925
- if (type == "generate") {
926
- if (tab == "pass") {
978
+ if (type === "generate") {
979
+ if (tabType === "pass") {
927
980
  dialog.value = true;
928
981
  dialogType.value = "generate";
929
982
  generatePass.value = true;
@@ -935,28 +988,23 @@ const closeDialog = async (type?: string, tab?: string) => {
935
988
  },
936
989
  });
937
990
  }
938
- selectedChoicePaperSizeOrientation.value = null;
939
- resultKeys2.value = [];
991
+ resetPrintState();
940
992
  snackbarStartRange.value = false;
941
993
  }
942
994
  };
943
995
 
944
996
  const fetchTemplateData = async (inputStatus: any) => {
945
997
  isFetchingTemplates.value = true;
946
- selectedChoicePaperSizeOrientation.value = null;
947
-
948
- startRange.value = null;
949
- endRange.value = null;
950
- resultKeys2.value = [];
998
+ resetPrintState();
951
999
 
952
1000
  const id = selectedTemplate.value
953
1001
  ? selectedTemplate.value?._id
954
- : props.template._id;
1002
+ : props.template?._id;
955
1003
 
956
1004
  const status = route.query.status as string;
957
1005
  const finalStatus =
958
1006
  typeof inputStatus === "string" ? inputStatus : String(inputStatus);
959
- let site = route.params.site as string;
1007
+ const site = route.params.site as string;
960
1008
  const data = await getTemplatesByPageSearch({
961
1009
  _id: id,
962
1010
  sites: [site],
@@ -964,7 +1012,7 @@ const fetchTemplateData = async (inputStatus: any) => {
964
1012
  statuses: [finalStatus ? finalStatus : status],
965
1013
  });
966
1014
 
967
- templateQrCode.value = data?.items[0];
1015
+ templateQrCode.value = data?.items?.[0] ?? null;
968
1016
 
969
1017
  isFetchingTemplates.value = false;
970
1018
  };
@@ -972,47 +1020,44 @@ const fetchTemplateData = async (inputStatus: any) => {
972
1020
  watch(
973
1021
  () => props.open,
974
1022
  async (newVal: any) => {
975
- if (newVal) {
976
- selectAll.value = false;
977
- if (props.template.name !== "All") {
978
- selectedTemplate.value = props.template;
979
- } else {
980
- selectedTemplate.value = null;
981
- }
982
- if (tab.value == "key") {
983
- selectedKeysToPrint.value = [];
984
- isFetchingPassKeys.value = true;
985
- resultKeys2.value = await getPassKeysByPageSearch({
986
- sites: [route.params.site as string],
987
- template: null,
988
- passOrKey: tab.value,
989
- passTypes: ["pass-key"],
990
- sortBy: { column: "createdAt", order: "1" },
991
- limit: 10,
992
- });
993
-
994
- totalPages.value = resultKeys2.value.pages;
995
- isFetchingPassKeys.value = false;
996
- } else {
997
- selectedChoicePaperSizeOrientation.value = props.orientation;
998
- await fetchTemplateData("active");
999
- }
1023
+ if (!newVal) return;
1024
+
1025
+ selectAll.value = false;
1026
+ selectedTemplate.value =
1027
+ props.template?.name !== "All" ? props.template : null;
1028
+
1029
+ if (isKeyTab.value) {
1030
+ selectedKeysToPrint.value = [];
1031
+ isFetchingPassKeys.value = true;
1032
+ keyListResult.value = await getPassKeysByPageSearch({
1033
+ sites: [route.params.site as string],
1034
+ template: null,
1035
+ passOrKey: tab.value,
1036
+ passTypes: ["pass-key"],
1037
+ sortBy: { column: "createdAt", order: "1" },
1038
+ limit: 10,
1039
+ });
1040
+
1041
+ totalPages.value = keyListResult.value?.pages ?? 0;
1042
+ isFetchingPassKeys.value = false;
1043
+ } else {
1044
+ selectedChoicePaperSizeOrientation.value = props.orientation;
1045
+ await fetchTemplateData("active");
1000
1046
  }
1001
1047
  },
1002
1048
  { immediate: true }
1003
1049
  );
1004
1050
 
1005
- const router = useRouter();
1006
-
1007
1051
  const printContent = () => {
1008
- const printRangeStart = startRange.value;
1009
- const printRangeEnd = endRange.value;
1010
- const printOrientation =
1011
- tab.value !== "key" ? selectedChoicePaperSizeOrientation.value : "KeyCard";
1052
+ const printRangeStart = startRange.value?.toString() ?? "";
1053
+ const printRangeEnd = endRange.value?.toString() ?? "";
1054
+ const printOrientation = isPassTab.value
1055
+ ? selectedChoicePaperSizeOrientation.value
1056
+ : "KeyCard";
1012
1057
  const status = (route.query.status as string) || "active";
1013
1058
  const templateParam =
1014
1059
  (route.query.template as string) || (selectedTemplate.value?._id as string);
1015
- const prefix = prefixAndName.value;
1060
+ const prefix = getPassNumberPrefix(prefixAndName.value);
1016
1061
 
1017
1062
  const url = router.resolve({
1018
1063
  name: "org-site-keys-visitor-printQr",
@@ -1028,121 +1073,89 @@ const printContent = () => {
1028
1073
  },
1029
1074
  }).href;
1030
1075
 
1031
- if (printOrientation == "KeyCard") {
1076
+ if (printOrientation === "KeyCard") {
1032
1077
  localStorage.setItem(
1033
1078
  "selectedKeysToPrint",
1034
1079
  JSON.stringify(selectedKeysToPrint.value)
1035
1080
  );
1036
1081
  }
1037
1082
 
1038
- // Open the URL in a new tab
1039
1083
  setTimeout(() => {
1040
1084
  window.open(url, "_blank");
1041
1085
  }, 500);
1042
1086
  };
1043
1087
 
1044
1088
  watch(selectedChoicePaperSizeOrientation, async (newVal: any) => {
1045
- resultKeys2.value = [];
1046
- const id = selectedTemplate.value
1047
- ? selectedTemplate.value?._id
1048
- : props.template._id;
1089
+ if (!isPassTab.value) return;
1090
+ if (!newVal || !selectedTemplateId.value) {
1091
+ passRangeOptions.value = [];
1092
+ prefixAndName.value = "";
1093
+ startRange.value = null;
1094
+ endRange.value = null;
1095
+ return;
1096
+ }
1049
1097
 
1050
1098
  isFetchingPassKeys.value = true;
1051
1099
 
1052
1100
  resultPass.value = await getPassKeysByPageSearch({
1053
1101
  sites: [route.params.site as string],
1054
- template: id,
1102
+ template: selectedTemplateId.value,
1055
1103
  passOrKey: tab.value,
1056
1104
  passTypes: ["visitor-pass", "agent-pass", "contractor-pass"],
1057
1105
  limit: 2000,
1058
1106
  sortBy: { column: "prefixAndName", order: "1" },
1059
1107
  });
1060
1108
 
1061
- resultKeys2.value = resultPass?.value.items.map((item: any) => ({
1062
- text: item.prefixAndName,
1063
- value: item.name,
1064
- }));
1065
-
1066
- if (resultKeys2.value.length > 0) {
1067
- prefixAndName.value = resultKeys2.value[0].text
1068
- .replace(/\d/g, "")
1069
- .toUpperCase();
1070
- }
1109
+ passRangeOptions.value = mapPassRangeItems(resultPass?.value?.items ?? []);
1071
1110
 
1072
- resultKeys2.value = resultPass?.value.items.map((item: any) => ({
1073
- text: item.prefixAndName,
1074
- value: item.name,
1075
- }));
1076
-
1077
- if (resultKeys2.value.length > 0) {
1078
- prefixAndName.value = resultKeys2.value[0].text
1079
- .replace(/\d/g, "")
1080
- .toUpperCase();
1111
+ if (passRangeOptions.value.length > 0) {
1112
+ syncPrefixFromSelection();
1113
+ } else {
1114
+ prefixAndName.value = "";
1081
1115
  }
1082
1116
 
1083
- resultKeys2.value.sort(
1084
- (firstItem: { value: string }, secondItem: { value: string }) => {
1085
- const numericValueOfFirstItem = Number(
1086
- firstItem.value.replace(/\D/g, "")
1087
- );
1088
- const numericValueOfSecondItem = Number(
1089
- secondItem.value.replace(/\D/g, "")
1090
- );
1091
-
1092
- return numericValueOfFirstItem - numericValueOfSecondItem;
1093
- }
1094
- );
1095
-
1096
- startRange.value = props.start.toString();
1117
+ startRange.value = props.start?.toString() ?? null;
1118
+ syncPrefixFromSelection();
1097
1119
  isFetchingPassKeys.value = false;
1098
1120
  });
1099
1121
 
1100
- const page = ref(1);
1101
-
1102
1122
  watch(startRange, (newVal: any, oldVal: any) => {
1103
1123
  if (newVal !== oldVal) {
1104
1124
  endRange.value = newVal;
1125
+ syncPrefixFromSelection();
1105
1126
  }
1106
1127
  });
1107
1128
 
1108
1129
  const endRangeKeys = computed(() => {
1109
- return resultKeys2.value.filter(
1110
- (item: any) => item.value >= startRange.value
1130
+ return passRangeOptions.value.filter(
1131
+ (item: PassRangeOption) => item.value >= (startRange.value ?? "")
1111
1132
  );
1112
1133
  });
1113
- const message = ref("");
1114
- const messageColor = ref("");
1115
- const messageSnackbar = ref(false);
1116
-
1117
- function showMessage(msg: string, color: string) {
1118
- message.value = msg;
1119
- messageColor.value = color;
1120
- messageSnackbar.value = true;
1121
- }
1122
1134
 
1123
1135
  const showSnackbarEndRange = () => {
1124
- if (resultKeys2.value.length === 0) {
1136
+ if (passRangeOptions.value.length === 0) {
1125
1137
  showMessage(
1126
1138
  !startRange.value
1127
1139
  ? "Please select a start range first."
1128
- : `No ${tab.value == "key" ? "Key" : "Pass"} found. Please try to
1129
- generate first.`,
1140
+ : `No ${
1141
+ tab.value === "key" ? "Key" : "Pass"
1142
+ } found. Please try to generate first.`,
1130
1143
  "error"
1131
1144
  );
1132
1145
  }
1133
1146
  };
1147
+
1134
1148
  const showSnackbarStartRange = () => {
1135
- if (resultKeys2.value.length === 0) {
1149
+ if (passRangeOptions.value.length === 0) {
1136
1150
  snackbarStartRange.value = true;
1137
1151
  }
1138
1152
  };
1139
1153
 
1140
- // if print key
1141
1154
  async function onSearch() {
1142
1155
  isFetchingPassKeys.value = true;
1143
1156
  try {
1144
1157
  page.value = 1;
1145
- resultKeys2.value = await getPassKeysByPageSearch({
1158
+ keyListResult.value = await getPassKeysByPageSearch({
1146
1159
  sites: [route.params.site as string],
1147
1160
  search: searchKey.value,
1148
1161
  template: null,
@@ -1152,8 +1165,8 @@ async function onSearch() {
1152
1165
  sortBy: { column: "createdAt", order: "1" },
1153
1166
  page: page.value,
1154
1167
  });
1155
- totalPages.value = resultKeys2.value.pages;
1156
- } catch (error) {
1168
+ totalPages.value = keyListResult.value?.pages ?? 0;
1169
+ } catch (error: any) {
1157
1170
  showMessage(errorConverter(error), "error");
1158
1171
  } finally {
1159
1172
  isFetchingPassKeys.value = false;
@@ -1162,7 +1175,7 @@ async function onSearch() {
1162
1175
 
1163
1176
  async function updateItemsPerPage() {
1164
1177
  isFetchingPassKeys.value = true;
1165
- resultKeys2.value = await getPassKeysByPageSearch({
1178
+ keyListResult.value = await getPassKeysByPageSearch({
1166
1179
  sites: [route.params.site as string],
1167
1180
  template: null,
1168
1181
  passOrKey: "key",
@@ -1171,14 +1184,14 @@ async function updateItemsPerPage() {
1171
1184
  page: page.value,
1172
1185
  limit: selectedPageRange.value,
1173
1186
  });
1174
- totalPages.value = resultKeys2.value.pages;
1187
+ totalPages.value = keyListResult.value?.pages ?? 0;
1175
1188
  isFetchingPassKeys.value = false;
1176
1189
  }
1177
1190
 
1178
1191
  async function prevPage() {
1179
1192
  isFetchingPassKeys.value = true;
1180
1193
  page.value -= 1;
1181
- resultKeys2.value = await getPassKeysByPageSearch({
1194
+ keyListResult.value = await getPassKeysByPageSearch({
1182
1195
  sites: [route.params.site as string],
1183
1196
  search: searchKey.value,
1184
1197
  template: null,
@@ -1189,14 +1202,14 @@ async function prevPage() {
1189
1202
  limit: selectedPageRange.value,
1190
1203
  });
1191
1204
 
1192
- totalPages.value = resultKeys2.value.pages;
1205
+ totalPages.value = keyListResult.value?.pages ?? 0;
1193
1206
  isFetchingPassKeys.value = false;
1194
1207
  }
1195
1208
 
1196
1209
  async function nextPage() {
1197
1210
  isFetchingPassKeys.value = true;
1198
1211
  page.value += 1;
1199
- resultKeys2.value = await getPassKeysByPageSearch({
1212
+ keyListResult.value = await getPassKeysByPageSearch({
1200
1213
  sites: [route.params.site as string],
1201
1214
  search: searchKey.value,
1202
1215
  template: null,
@@ -1207,7 +1220,7 @@ async function nextPage() {
1207
1220
  limit: selectedPageRange.value,
1208
1221
  });
1209
1222
 
1210
- totalPages.value = resultKeys2.value.pages;
1223
+ totalPages.value = keyListResult.value?.pages ?? 0;
1211
1224
  isFetchingPassKeys.value = false;
1212
1225
  }
1213
1226
  </script>
@@ -588,7 +588,7 @@
588
588
  :org="orgId"
589
589
  :site="siteId"
590
590
  :visitor-data="selectedVisitorDataObject"
591
- :current-user="currentUser._id"
591
+ :current-user="currentUser?._id"
592
592
  :type="activeVisitorFormType"
593
593
  :enable-unregistered="enableUnregistered"
594
594
  @back="handleClickBack"