@7365admin1/layer-common 1.11.27 → 1.11.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 1.11.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 1fa1e46: Update layer-common
8
+
9
+ ## 1.11.28
10
+
11
+ ### Patch Changes
12
+
13
+ - 21ced98: Update Site Settings
14
+
3
15
  ## 1.11.27
4
16
 
5
17
  ### Patch Changes
@@ -435,8 +435,6 @@ const prop = defineProps({
435
435
  });
436
436
 
437
437
  const { add: _addCard, updateById: _updateCardById } = useCard();
438
- const { getAll: _getBuildings } = useBuilding();
439
- const { getAllUnits: _getUnits } = useBuildingUnit();
440
438
  const {
441
439
  getDoorAccessLevels: _getDoorAccessLevels,
442
440
  getLiftAccessLevels: _getLiftAccessLevels,
@@ -444,6 +442,7 @@ const {
444
442
  addPhysicalCard: _addPhysicalCard,
445
443
  addNonPhysicalCard: _addNonPhysicalCard,
446
444
  bulkPhysicalAccessCard: _bulkPhysicalAccessCard,
445
+ getBlockLevelUnitList: _getBlockLevelUnitList,
447
446
  } = useAccessManagement();
448
447
  const { getBySiteId: _getEntryPassSettings } = useSiteEntryPassSettings();
449
448
  const { getFileUrl } = useFile();
@@ -570,7 +569,7 @@ const liftAccessLevelItems = ref<{ name: string; no: string }[]>([]);
570
569
  const buildingItems = ref<{ name: string; value: string }[]>([]);
571
570
  const levelItems = ref<{ name: string; value: string }[]>([]);
572
571
  const unitItems = ref<{ name: string; value: string }[]>([]);
573
- const buildingsData = ref<Record<string, any>[]>([]);
572
+ const blockLevelUnitData = ref<any[]>([]);
574
573
  const encryptedAcmUrl = ref("");
575
574
 
576
575
  const route = useRoute();
@@ -644,28 +643,24 @@ function updateEndDate(startDate: string | null) {
644
643
  }
645
644
  }
646
645
 
647
- // Watch for Assign toggle to fetch buildings
646
+ // Watch for Assign toggle to fetch block/level/unit data
648
647
  watch(() => card.value.showAssign, async (newVal) => {
649
648
  if (newVal) {
650
649
  try {
651
- const response = await _getBuildings({
652
- page: 1,
653
- status: "active",
654
- site: siteId,
655
- });
656
- buildingsData.value = response.items || [];
657
- buildingItems.value = buildingsData.value.map((building: any) => ({
658
- name: building.block,
659
- value: building._id,
650
+ const response = await _getBlockLevelUnitList(siteId);
651
+ blockLevelUnitData.value = (response as any)?.data || [];
652
+ buildingItems.value = blockLevelUnitData.value.map((b: any) => ({
653
+ name: b.block,
654
+ value: b._id,
660
655
  }));
661
656
  } catch (error) {
662
- console.error("Failed to fetch buildings:", error);
657
+ console.error("Failed to fetch block/level/unit list:", error);
663
658
  }
664
659
  } else {
665
- // Reset selections when toggled off
666
660
  card.value.assignBuilding = "";
667
661
  card.value.assignLevel = "";
668
662
  card.value.assignUnit = "";
663
+ blockLevelUnitData.value = [];
669
664
  buildingItems.value = [];
670
665
  levelItems.value = [];
671
666
  unitItems.value = [];
@@ -673,51 +668,35 @@ watch(() => card.value.showAssign, async (newVal) => {
673
668
  });
674
669
 
675
670
  // Watch for building selection to populate levels
676
- watch(() => card.value.assignBuilding, async (newVal) => {
671
+ watch(() => card.value.assignBuilding, (newVal) => {
672
+ card.value.assignLevel = "";
673
+ card.value.assignUnit = "";
674
+ unitItems.value = [];
675
+
677
676
  if (newVal) {
678
- const selectedBuilding = buildingsData.value.find((b: any) => b._id === newVal);
679
- if (selectedBuilding && selectedBuilding.levels) {
680
- levelItems.value = selectedBuilding.levels.map((level: string) => ({
681
- name: level,
682
- value: level,
683
- }));
684
- }
685
- // Reset level and unit when building changes
686
- card.value.assignLevel = "";
687
- card.value.assignUnit = "";
688
- unitItems.value = [];
677
+ const selectedBlock = blockLevelUnitData.value.find((b: any) => b._id === newVal);
678
+ levelItems.value = selectedBlock?.levels?.map((l: any) => ({
679
+ name: l.level,
680
+ value: l._id,
681
+ })) || [];
689
682
  } else {
690
683
  levelItems.value = [];
691
- card.value.assignLevel = "";
692
- card.value.assignUnit = "";
693
- unitItems.value = [];
694
684
  }
695
685
  });
696
686
 
697
- // Watch for level selection to fetch units
698
- watch(() => card.value.assignLevel, async (newVal) => {
687
+ // Watch for level selection to populate units
688
+ watch(() => card.value.assignLevel, (newVal) => {
689
+ card.value.assignUnit = "";
690
+
699
691
  if (newVal && card.value.assignBuilding) {
700
- try {
701
- const response = await _getUnits({
702
- page: 1,
703
- status: "active",
704
- site: siteId,
705
- building: card.value.assignBuilding,
706
- });
707
- const units = response.items || [];
708
- // Filter units by selected level
709
- const filteredUnits = units.filter((unit: any) => unit.level === newVal);
710
- unitItems.value = filteredUnits.map((unit: any) => ({
711
- name: unit.name,
712
- value: unit._id,
713
- }));
714
- } catch (error) {
715
- console.error("Failed to fetch units:", error);
716
- }
717
- card.value.assignUnit = "";
692
+ const selectedBlock = blockLevelUnitData.value.find((b: any) => b._id === card.value.assignBuilding);
693
+ const selectedLevel = selectedBlock?.levels?.find((l: any) => l._id === newVal);
694
+ unitItems.value = selectedLevel?.units?.map((u: any) => ({
695
+ name: u.name,
696
+ value: u._id,
697
+ })) || [];
718
698
  } else {
719
699
  unitItems.value = [];
720
- card.value.assignUnit = "";
721
700
  }
722
701
  });
723
702
 
@@ -68,7 +68,6 @@
68
68
  persistent-placeholder
69
69
  :rules="[requiredArrayRule]"
70
70
  :disabled="!form.level"
71
- :loading="unitLoading"
72
71
  multiple
73
72
  chips
74
73
  closable-chips
@@ -209,9 +208,8 @@ const {
209
208
  getLiftAccessLevels: _getLiftAccessLevels,
210
209
  assignAccessCard: _assignAccessCard,
211
210
  getAvailableAccessCards: _getAvailableAccessCards,
211
+ getBlockLevelUnitList: _getBlockLevelUnitList,
212
212
  } = useAccessManagement();
213
- const { getAll: _getBuildings } = useBuilding();
214
- const { getAllUnits: _getUnits } = useBuildingUnit();
215
213
  const { requiredRule } = useUtils();
216
214
 
217
215
  const route = useRoute();
@@ -221,7 +219,6 @@ const validForm = ref(false);
221
219
  const loading = ref(false);
222
220
  const levelsLoading = ref(false);
223
221
  const buildingLoading = ref(false);
224
- const unitLoading = ref(false);
225
222
  const availableLoading = ref(false);
226
223
  const availableCount = ref<number | null>(null);
227
224
 
@@ -245,7 +242,7 @@ const NO_SELECTION = { name: "No Selection", no: null };
245
242
  const accessLevelItems = ref<{ name: string; no: string | null }[]>([]);
246
243
  const liftAccessLevelItems = ref<{ name: string; no: string | null }[]>([]);
247
244
  const buildingItems = ref<{ name: string; value: string }[]>([]);
248
- const buildingsData = ref<Record<string, any>[]>([]);
245
+ const blockLevelUnitData = ref<any[]>([]);
249
246
  const levelItems = ref<{ name: string; value: string }[]>([]);
250
247
  const unitItems = ref<{ name: string; value: string }[]>([]);
251
248
 
@@ -303,15 +300,15 @@ onMounted(async () => {
303
300
  buildingLoading.value = true;
304
301
  levelsLoading.value = true;
305
302
 
306
- const [buildingsResult, acmResult] = await Promise.allSettled([
307
- _getBuildings({ page: 1, status: "active", site: siteId.value }),
303
+ const [blockLevelResult, acmResult] = await Promise.allSettled([
304
+ _getBlockLevelUnitList(siteId.value),
308
305
  $fetch<{ encrypted: string }>("/api/encrypt-acm-url"),
309
306
  ]);
310
307
 
311
- // Buildings
312
- if (buildingsResult.status === "fulfilled") {
313
- buildingsData.value = buildingsResult.value.items || [];
314
- buildingItems.value = buildingsData.value.map((b: any) => ({
308
+ // Blocks / Levels / Units
309
+ if (blockLevelResult.status === "fulfilled") {
310
+ blockLevelUnitData.value = (blockLevelResult.value as any)?.data || [];
311
+ buildingItems.value = blockLevelUnitData.value.map((b: any) => ({
315
312
  name: b.block,
316
313
  value: b._id,
317
314
  }));
@@ -345,20 +342,18 @@ onMounted(async () => {
345
342
 
346
343
  watch(
347
344
  () => form.value.building,
348
- async (newVal) => {
345
+ (newVal) => {
349
346
  form.value.level = null;
350
347
  form.value.units = [];
351
348
  levelItems.value = [];
352
349
  unitItems.value = [];
353
350
 
354
351
  if (newVal) {
355
- const selectedBuilding = buildingsData.value.find(
356
- (b: any) => b._id === newVal
357
- );
358
- if (selectedBuilding?.levels) {
359
- levelItems.value = selectedBuilding.levels.map((level: string) => ({
360
- name: level,
361
- value: level,
352
+ const selectedBlock = blockLevelUnitData.value.find((b: any) => b._id === newVal);
353
+ if (selectedBlock?.levels) {
354
+ levelItems.value = selectedBlock.levels.map((l: any) => ({
355
+ name: l.level,
356
+ value: l._id,
362
357
  }));
363
358
  }
364
359
  }
@@ -367,29 +362,18 @@ watch(
367
362
 
368
363
  watch(
369
364
  () => form.value.level,
370
- async (newVal) => {
365
+ (newVal) => {
371
366
  form.value.units = [];
372
367
  unitItems.value = [];
373
368
 
374
369
  if (newVal && form.value.building) {
375
- unitLoading.value = true;
376
- try {
377
- const response = await _getUnits({
378
- page: 1,
379
- status: "active",
380
- site: siteId.value,
381
- building: form.value.building,
382
- });
383
- const units = response.items || [];
384
- const filtered = units.filter((u: any) => u.level === newVal);
385
- unitItems.value = filtered.map((u: any) => ({
370
+ const selectedBlock = blockLevelUnitData.value.find((b: any) => b._id === form.value.building);
371
+ const selectedLevel = selectedBlock?.levels?.find((l: any) => l._id === newVal);
372
+ if (selectedLevel?.units) {
373
+ unitItems.value = selectedLevel.units.map((u: any) => ({
386
374
  name: u.name,
387
375
  value: u._id,
388
376
  }));
389
- } catch {
390
- console.error("Failed to fetch units");
391
- } finally {
392
- unitLoading.value = false;
393
377
  }
394
378
  }
395
379
  }
@@ -152,7 +152,7 @@ const props = defineProps({
152
152
  default: () => [
153
153
  {
154
154
  title: "Block",
155
- value: "block.name",
155
+ value: "block.block",
156
156
  },
157
157
  {
158
158
  title: "Level",
@@ -131,6 +131,13 @@
131
131
  </template>
132
132
 
133
133
  <script setup lang="ts">
134
+ import useCustomerSite from '../composables/useCustomerSite';
135
+ import useLocal from '../composables/useLocal';
136
+ import { useLocalSetup } from '../composables/useLocalSetup';
137
+ import useRole from '../composables/useRole';
138
+ import useUser from '../composables/useUser';
139
+ import useUtils from '../composables/useUtils';
140
+
134
141
  const APP = useRuntimeConfig().public.APP;
135
142
  const props = defineProps({
136
143
  title: {
@@ -190,6 +197,7 @@ const invite = ref<Record<string, any>>({
190
197
  org: "",
191
198
  site: "",
192
199
  siteName: "",
200
+ isMemberInvite: false,
193
201
  });
194
202
 
195
203
  invite.value.app = props.app;
@@ -298,9 +306,14 @@ const roles = ref<Array<Record<string, any>>>([]);
298
306
  const { getRoles } = useRole();
299
307
 
300
308
  const { data: RolesData, refresh: refreshRoles } = await useLazyAsyncData(
301
- "get-roles-by-type",
302
- () => getRoles({ org: props.org, type: app.value, limit: 50 }),
303
- { watch: [app] }
309
+ "get-roles-by-type-" + props.org + "-" + props.app,
310
+ () =>
311
+ getRoles({
312
+ org: props.org,
313
+ type: props.app,
314
+ limit: 50,
315
+ }),
316
+ { watch: [() => props.app] }
304
317
  );
305
318
 
306
319
  watchEffect(() => {
@@ -309,10 +322,10 @@ watchEffect(() => {
309
322
  }
310
323
  });
311
324
 
312
- function handleUpdateApp(value: string) {
325
+ async function handleUpdateApp(value: string) {
313
326
  invite.value.role = "";
314
327
  invite.value.site = "";
315
- refreshRoles();
328
+ await refreshRoles()
316
329
  }
317
330
 
318
331
  const createMore = ref(false);
@@ -91,6 +91,9 @@
91
91
  </template>
92
92
 
93
93
  <script setup lang="ts">
94
+ import useRole from '../composables/useRole';
95
+ import useUtils from '../composables/useUtils';
96
+
94
97
  const props = defineProps({
95
98
  title: {
96
99
  type: String,
@@ -111,6 +111,9 @@
111
111
  </template>
112
112
 
113
113
  <script setup lang="ts">
114
+ import useRole from '../composables/useRole';
115
+ import useUtils from '../composables/useUtils';
116
+
114
117
  const definedModel = defineModel<Array<string>>({
115
118
  default: () => [],
116
119
  });
@@ -327,6 +327,8 @@
327
327
  </template>
328
328
 
329
329
  <script lang="ts" setup>
330
+ import useServiceProvider from '../composables/useServiceProvider';
331
+
330
332
  const props = defineProps({
331
333
  orgId: {
332
334
  type: String,
@@ -418,7 +420,7 @@ const serviceProvider = ref({
418
420
  const {
419
421
  getAll: getAllServiceProvider,
420
422
  add: addServiceProvider,
421
- invite: inviteServiceProvider,
423
+ createServiceProviderInvite
422
424
  } = useServiceProvider();
423
425
 
424
426
  const { getSiteById } = useSite();
@@ -536,12 +538,15 @@ async function submitServiceProviderInvite() {
536
538
  disableServiceProvider.value = true;
537
539
  messageServiceProvider.value = "";
538
540
  try {
539
- await inviteServiceProvider({
540
- email: serviceProvider.value.email,
541
- orgId: props.orgId,
542
- siteId: props.siteId,
543
- siteName: site.value?.name ?? "",
544
- });
541
+ const payload = {
542
+ email: serviceProvider.value.email?.trim(),
543
+ orgId: props.orgId,
544
+ siteId: props.siteId,
545
+ siteName: site.value?.name || props.siteName,
546
+ };
547
+
548
+
549
+ await createServiceProviderInvite(payload);
545
550
  if (createMoreServiceProvider.value) {
546
551
  serviceProvider.value.email = "";
547
552
  } else {