@7365admin1/layer-common 1.11.53 → 2.0.0

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
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - f4ee57d: Refactor Building Management Module
8
+
9
+ ## 1.11.54
10
+
11
+ ### Patch Changes
12
+
13
+ - 4eeaa88: add member site and org query params
14
+
3
15
  ## 1.11.53
4
16
 
5
17
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  <v-toolbar>
4
4
  <v-row no-gutters class="fill-height px-6" align="center">
5
5
  <span class="font-weight-bold text-h5 text-capitalize">
6
- {{ prop.mode }} Block
6
+ {{ prop.mode }} Block {{ (prop.mode === "edit" && building.block) ? `- ${building.block}` : "" }}
7
7
  </span>
8
8
  </v-row>
9
9
  </v-toolbar>
@@ -12,21 +12,21 @@
12
12
  <v-row no-gutters class="px-6 pt-4">
13
13
  <v-col cols="12" class="mt-2">
14
14
  <v-row no-gutters>
15
- <InputLabel class="text-capitalize font-weight-bold" title="Name" required />
15
+ <InputLabel class="text-capitalize font-weight-bold" title="Block Name" required />
16
16
  <v-col cols="12">
17
17
  <v-text-field v-model="building.name" density="comfortable" :rules="[requiredRule]"></v-text-field>
18
18
  </v-col>
19
19
  </v-row>
20
20
  </v-col>
21
21
 
22
- <v-col cols="12">
22
+ <v-col v-if="prop.mode === 'add'" cols="12">
23
23
  <v-row>
24
24
  <v-col cols="6" class="mt-2">
25
25
  <v-row no-gutters>
26
- <InputLabel class="text-capitalize font-weight-bold" title="Block" required />
26
+ <InputLabel class="text-capitalize font-weight-bold" title="Block No." required />
27
27
  <v-col cols="12">
28
28
  <v-select v-model.number="building.block" :items="blocks" item-title="label" item-value="value"
29
- density="comfortable" :disabled="prop.mode === 'edit'" :rules="[
29
+ density="comfortable" :rules="[
30
30
  requiredRule,
31
31
  () =>
32
32
  (building.block && building.block > 0) ||
@@ -43,7 +43,7 @@
43
43
 
44
44
  <v-col cols="6" class="mt-2">
45
45
  <v-row no-gutters>
46
- <InputLabel class="text-capitalize font-weight-bold" title="Levels" required />
46
+ <InputLabel class="text-capitalize font-weight-bold" title="No. of Levels" required />
47
47
  <v-col cols="12">
48
48
  <v-text-field v-model.number="buildingLevels" density="comfortable" :rules="[requiredRule]"
49
49
  type="number" @update:model-value="setBuildingLevels()"></v-text-field>
@@ -53,24 +53,33 @@
53
53
  </v-row>
54
54
  </v-col>
55
55
 
56
- <v-col v-if="buildingLevels" cols="12">
56
+ <!-- <v-col v-if="buildingLevels &&" cols="12">
57
57
  <v-row justify="center">
58
58
  <v-col cols="6">
59
59
  <v-btn block color="primary" variant="text" class="text-none font-weight-bold" text="Set level labels"
60
60
  @click="show = !show"></v-btn>
61
61
  </v-col>
62
62
  </v-row>
63
- </v-col>
63
+ </v-col> -->
64
+ </v-row>
65
+
66
+ <v-row no-gutters v-if="building.levels.length > 0 || newLevelsArray.length > 0" class="mt-2">
67
+ <InputLabel class="text-capitalize font-weight-bold px-6 mb-2" title="Levels" />
64
68
  </v-row>
65
69
 
66
70
  <v-expand-transition>
67
- <v-row v-show="show" no-gutters class="px-6">
71
+ <v-row v-if="prop.mode === 'edit'" no-gutters class="px-6">
68
72
  <template v-for="(level, levelIndex) in building.levels" :key="levelIndex">
69
73
  <v-col cols="12">
70
74
  <v-row no-gutters>
71
- <InputLabel class="text-capitalize font-weight-bold" :title="`Level ${levelIndex + 1}`" />
72
- <v-col cols="12">
73
- <v-text-field v-model.trim="building.levels[levelIndex]" density="comfortable"></v-text-field>
75
+ <v-col :cols="prop.mode === 'edit' ? 10 : 12">
76
+ <v-text-field v-model.trim="building.levels[levelIndex].name" density="comfortable"></v-text-field>
77
+ </v-col>
78
+ <v-col v-if="prop.mode === 'edit'" cols="2" class="d-flex align-center pb-5 justify-end">
79
+ <v-btn icon variant="text" color="error" :disabled="disable"
80
+ @click="openDeleteLevelPrompt(levelIndex)">
81
+ <v-icon icon="mdi-trash-can-outline"></v-icon>
82
+ </v-btn>
74
83
  </v-col>
75
84
  </v-row>
76
85
  </v-col>
@@ -78,9 +87,43 @@
78
87
  </v-row>
79
88
  </v-expand-transition>
80
89
 
90
+
91
+
92
+ <v-row no-gutters class="px-6 w-100">
93
+ <v-row no-gutters v-for="(newLevelsItem, index) in newLevelsArray" :key="index" :cols="12" class="w-100">
94
+ <v-text-field v-model.trim="newLevelsArray[index]" density="comfortable"></v-text-field>
95
+ <v-col cols="2" class="d-flex align-center pb-5 justify-end">
96
+ <v-btn icon variant="text" color="error" @click="newLevelsArray.splice(index, 1)">
97
+ <v-icon icon="mdi-trash-can-outline"></v-icon>
98
+ </v-btn>
99
+ </v-col>
100
+ </v-row>
101
+ </v-row>
102
+
103
+ <v-row v-if="prop.mode === 'edit'" no-gutters class="px-6 w-100">
104
+ <v-col cols="10">
105
+ <v-text-field v-model.trim="activeNewLevelInput" density="comfortable" class="w-100"
106
+ placeholder="Add new level" @click="addNewLevelErrorMessage = ''"></v-text-field>
107
+ </v-col>
108
+ <v-col cols="2" class="d-flex align-center pb-5 justify-end">
109
+ <v-btn icon variant="text" @click="addNewLevel()">
110
+ <v-icon icon="mdi-plus"></v-icon>
111
+ </v-btn>
112
+ </v-col>
113
+ </v-row>
114
+ <v-row v-if="prop.mode === 'edit'" no-gutters class="px-6 mb-2">
115
+ <span class="text-caption text-error">
116
+ {{ addNewLevelErrorMessage }}
117
+ </span>
118
+ </v-row>
119
+
120
+
121
+
122
+
81
123
  <v-col cols="12" class="px-6">
82
- <InputLabel class="text-capitalize" title="Building Floor plan" />
83
- <InputFileV2 v-model="building.buildingFiles" :multiple="true" accept="*" :max-length="10" title="Upload Files" />
124
+ <InputLabel class="text-capitalize font-weight-bold" title="Building Floor plan" />
125
+ <InputFileV2 v-model="building.buildingFiles" :multiple="true" accept="*" :max-length="10"
126
+ title="Upload Files" />
84
127
  </v-col>
85
128
 
86
129
  <v-col cols="12" class="mt-2">
@@ -121,10 +164,40 @@
121
164
  </v-col>
122
165
  </v-row>
123
166
  </v-toolbar>
167
+
168
+ <ConfirmDialog v-model="confirmDeleteLevelDialog" :loading="loading.deletingLevel" width="450" persistent>
169
+ <template #title>
170
+ Delete Level
171
+ </template>
172
+
173
+ <template #description>
174
+ Are you sure you want to delete {{ levelPendingDeleteName || "this level" }}?
175
+ </template>
176
+
177
+ <template #footer>
178
+ <v-row no-gutters class="w-100">
179
+ <v-col cols="6">
180
+ <v-btn tile block size="48" variant="text" class="text-none" :disabled="loading.deletingLevel"
181
+ @click="closeDeleteLevelPrompt">
182
+ Cancel
183
+ </v-btn>
184
+ </v-col>
185
+
186
+ <v-col cols="6">
187
+ <v-btn tile block size="48" variant="flat" color="error" class="text-none" :loading="loading.deletingLevel"
188
+ :disabled="loading.deletingLevel" @click="confirmDeleteLevel">
189
+ Delete
190
+ </v-btn>
191
+ </v-col>
192
+ </v-row>
193
+ </template>
194
+ </ConfirmDialog>
124
195
  </v-card>
125
196
  </template>
126
197
 
127
198
  <script setup lang="ts">
199
+ import InputLabel from './InputLabel.vue';
200
+
128
201
  const prop = defineProps({
129
202
  site: {
130
203
  type: String,
@@ -152,6 +225,7 @@ const prop = defineProps({
152
225
 
153
226
  const { getSiteById } = useSite();
154
227
  const { getFileById } = useFile();
228
+ const { deleteById, batchUpdateLevels } = useBuildingLevel();
155
229
 
156
230
  const site = ref<TSite | null>(null);
157
231
 
@@ -184,21 +258,64 @@ const blocks = computed(() => {
184
258
  return formattedArray;
185
259
  });
186
260
 
187
- const emit = defineEmits(["cancel", "success", "success:create-more"]);
261
+ const emit = defineEmits(["cancel", "success", "success:create-more", "refresh"]);
188
262
 
189
263
  const validForm = ref(false);
190
264
 
191
265
  const buildingLevels = ref(0);
266
+ const newLevelsArray = ref<string[]>([])
267
+ const activeNewLevelInput = ref<string>("")
268
+ const addNewLevelErrorMessage = ref("");
269
+
270
+ const loading = reactive({
271
+ deletingLevel: false,
272
+ });
192
273
 
193
274
  const show = ref(false);
275
+ const confirmDeleteLevelDialog = ref(false);
276
+ const levelPendingDeleteIndex = ref<number | null>(null);
277
+ const levelActionLoading = ref(false);
278
+
279
+ const levelPendingDeleteName = computed(() => {
280
+ if (levelPendingDeleteIndex.value === null) return "";
281
+ return building.value.levels[levelPendingDeleteIndex.value]?.name ?? "";
282
+ });
194
283
 
195
284
  function setBuildingLevels() {
196
- building.value.levels.length = 0;
285
+ newLevelsArray.value = [];
197
286
  for (let index = 0; index < buildingLevels.value; index++) {
198
- building.value.levels.push(`Lvl${index + 1}`);
287
+ newLevelsArray.value.push(`Lvl${index + 1}`);
199
288
  }
200
289
  }
201
290
 
291
+ // function addNewLevels() {
292
+ // const levelsToAdd = newLevelsInput.value
293
+ // .split(/\r?\n|,/)
294
+ // .map((item) => item.trim())
295
+ // .filter(Boolean);
296
+
297
+ // if (!levelsToAdd.length) return;
298
+ // buildingLevels.value = building.value.levels.length;
299
+ // newLevelsInput.value = "";
300
+ // }
301
+
302
+ function openDeleteLevelPrompt(levelIndex: number) {
303
+ levelPendingDeleteIndex.value = levelIndex;
304
+ confirmDeleteLevelDialog.value = true;
305
+ }
306
+
307
+ function closeDeleteLevelPrompt() {
308
+ confirmDeleteLevelDialog.value = false;
309
+ levelPendingDeleteIndex.value = null;
310
+ }
311
+
312
+ async function deleteLevelPlaceholder(levelName: string, levelIndex: number) {
313
+ // Placeholder integration for future delete-level API call.
314
+ return { success: true, levelName, levelIndex };
315
+ }
316
+
317
+
318
+
202
319
  const building = ref<TBuilding>({
203
320
  site: "",
204
321
  name: "",
@@ -207,13 +324,17 @@ const building = ref<TBuilding>({
207
324
  buildingFiles: []
208
325
  });
209
326
 
327
+ const initialBuildingLevels = ref([])
328
+
210
329
  // Normalize buildingFiles: extract IDs for InputFileV2, keep names in a separate map
211
330
  const buildingFilesNames = ref<Record<string, string>>({});
212
331
 
213
332
  building.value.site = prop.site;
214
333
  if (prop.mode === "edit") {
215
334
  building.value = JSON.parse(JSON.stringify(prop.building));
335
+ building.value.levels = building.value.levels.map((level: any) => ({ _id: level._id, name: level.name })); //temporary
216
336
  buildingLevels.value = building.value.levels.length;
337
+ initialBuildingLevels.value = JSON.parse(JSON.stringify(building.value.levels));
217
338
 
218
339
  const rawFiles = building.value.buildingFiles as any[];
219
340
  if (rawFiles?.length && typeof rawFiles[0] === 'object') {
@@ -256,16 +377,34 @@ async function submit() {
256
377
  try {
257
378
  if (prop.mode === "add") {
258
379
  const buildingPayload = { ...building.value };
259
- buildingPayload.buildingFiles = (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" }));
260
- await createBuilding(buildingPayload);
380
+
381
+ let payload: TBuildingPayload = {
382
+ site: buildingPayload.site,
383
+ name: buildingPayload.name,
384
+ block: buildingPayload.block,
385
+ levels: [...newLevelsArray.value],
386
+ buildingFiles: (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" }))
387
+ };
388
+
389
+ await createBuilding(payload);
261
390
  }
262
391
 
263
392
  if (prop.mode === "edit") {
393
+
394
+ console.log('Updating building with levels:', building.value.levels);
395
+
396
+ if(JSON.stringify(initialBuildingLevels.value) !== JSON.stringify(building.value.levels)) {
397
+ await batchUpdateLevels(building.value.levels as { _id: string; name: string }[]);
398
+ }
399
+
400
+ const newLevels = [...newLevelsArray.value, ...(activeNewLevelInput.value.trim() ? [activeNewLevelInput.value.trim()] : [])];
401
+
264
402
  await updateById(building.value._id ?? "", {
265
403
  name: building.value.name,
266
404
  block: building.value.block,
267
- levels: building.value.levels,
268
- buildingFiles: (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" }))
405
+ // levels: building.value.levels,
406
+ buildingFiles: (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" })),
407
+ ...(newLevels.length > 0 ? { levels: newLevels } : {})
269
408
  });
270
409
  }
271
410
 
@@ -288,6 +427,49 @@ async function submit() {
288
427
  }
289
428
  }
290
429
 
430
+
431
+ const addNewLevel = () => {
432
+ if (!activeNewLevelInput.value.trim()) {
433
+ addNewLevelErrorMessage.value = "Please fill in the current new level before adding another.";
434
+ return;
435
+ }
436
+ newLevelsArray.value.push(activeNewLevelInput.value);
437
+ activeNewLevelInput.value = "";
438
+ }
439
+
440
+ const confirmDeleteLevel = async () => {
441
+ const levelIndex = levelPendingDeleteIndex.value;
442
+ if (levelIndex === null) {
443
+ console.error("No level selected for deletion.");
444
+ return;
445
+ }
446
+ const levelId = building.value.levels[levelIndex]._id;
447
+ if (!levelId) {
448
+ console.error("Level ID is missing. Cannot delete level.");
449
+ return;
450
+ }
451
+
452
+ try {
453
+ loading.deletingLevel = true;
454
+ await deleteById(levelId);
455
+ const index = building.value.levels.findIndex(level => level._id === levelId);
456
+ closeDeleteLevelPrompt();
457
+ if (index !== -1) {
458
+ building.value.levels.splice(index, 1);
459
+ buildingLevels.value = building.value.levels.length;
460
+ }
461
+ emit('refresh')
462
+ } catch (error: any) {
463
+ console.error("Failed to delete level:", error);
464
+ const message = error.response?._data?.message || "Failed to delete level";
465
+ message.value = message;
466
+ } finally {
467
+ loading.deletingLevel = false;
468
+ }
469
+
470
+
471
+ }
472
+
291
473
  watch(buildingLevels, (newVal) => {
292
474
  setTimeout(() => {
293
475
  show.value = newVal > 0 && !!newVal;
@@ -43,12 +43,12 @@
43
43
  <v-dialog v-model="createDialog" width="450" persistent>
44
44
  <BuildingForm :site="site" :blocks="items" @cancel="createDialog = false" @success="successCreate()"
45
45
  @success:create-more="getBuildings()" />
46
- </v-dialog>
46
+ </v-dialog>
47
47
 
48
48
  <!-- Edit Dialog -->
49
49
  <v-dialog v-model="editDialog" width="450" persistent>
50
50
  <BuildingForm :site="site" :blocks="items" mode="edit" @cancel="editDialog = false" @success="successUpdate()"
51
- :building="selectedBuilding" />
51
+ :building="selectedBuilding" @refresh="getBuildings()" />
52
52
  </v-dialog>
53
53
 
54
54
  <!-- Preview Dialog -->
@@ -103,7 +103,7 @@ const props = defineProps({
103
103
  },
104
104
  {
105
105
  title: "Level",
106
- value: "level",
106
+ value: "level.name",
107
107
  },
108
108
  {
109
109
  title: "Block",
@@ -31,12 +31,12 @@
31
31
  item-value="_id" v-model:search="searchBuilding" :hide-no-data="false" density="comfortable"
32
32
  :rules="[requiredRule]" variant="outlined">
33
33
  <template v-slot:item="{ props: itemProps, item }">
34
- <v-list-item v-bind="itemProps" :title="`Block ${item?.raw?.block} (${item?.raw?.name})`">
34
+ <v-list-item v-bind="itemProps" :title="item?.raw?.name">
35
35
 
36
36
  </v-list-item>
37
37
  </template>
38
38
  <template v-slot:selection="{ item }">
39
- {{ buildingUnit.building && `Block ${item?.raw?.block} (${item?.raw?.name})` }}
39
+ {{ buildingUnit.building && `${item?.raw?.name}` }}
40
40
  </template>
41
41
  </v-autocomplete>
42
42
  </v-col>
@@ -47,7 +47,7 @@
47
47
  <v-row no-gutters>
48
48
  <InputLabel class="text-capitalize" title="Level" required />
49
49
  <v-col cols="12">
50
- <v-select v-model="buildingUnit.level" :items="buildingLevels" density="comfortable"
50
+ <v-select v-model="buildingUnit.level" :items="buildingLevels" item-title="name" item-value="_id" density="comfortable"
51
51
  :rules="[requiredRule]"></v-select>
52
52
  </v-col>
53
53
  </v-row>
@@ -275,7 +275,7 @@ watchEffect(() => {
275
275
 
276
276
  const buildingUnitQty = ref(1);
277
277
 
278
- const buildingUnit = ref<TBuildingUnit>({
278
+ const buildingUnit = ref<TBuildingUnitPayload>({
279
279
  site: "",
280
280
  name: "Unit",
281
281
  building: "",
@@ -29,10 +29,11 @@
29
29
 
30
30
  <v-col cols="12" md="6" lg="4" class="mt-2">
31
31
  <v-row no-gutters>
32
- <InputLabel class="text-capitalize font-weight-bold" title="Level" required />
32
+ <InputLabel class="text-capitalize font-weight-bold" title="Level"/>
33
33
  <v-col cols="12">
34
- <v-select v-model="buildingUnit.level" :items="buildingLevels" density="comfortable"
35
- :rules="[requiredRule]"></v-select>
34
+ <!-- <v-select v-model="buildingUnit.level" :items="buildingLevels" readonly item-title="name" class="no-pointer" item-value="_id" density="comfortable"
35
+ :rules="[requiredRule]"></v-select> -->
36
+ <v-text-field :model-value="buildingUnit.level.name" density="comfortable" readonly class="no-pointer" />
36
37
  </v-col>
37
38
  </v-row>
38
39
  </v-col>
@@ -43,7 +44,7 @@
43
44
  <v-row no-gutters>
44
45
  <InputLabel class="text-capitalize font-weight-bold" title="Block Name" />
45
46
  <v-col cols="12">
46
- <v-text-field :model-value="`Block ${buildingUnit.block} (${buildingUnit.buildingName})`"
47
+ <v-text-field :model-value="buildingUnit.buildingName"
47
48
  density="comfortable" readonly class="no-pointer"></v-text-field>
48
49
  </v-col>
49
50
  </v-row>
@@ -328,7 +329,10 @@ const buildingUnit = ref({
328
329
  ownerName: "",
329
330
  building: "",
330
331
  buildingName: "",
331
- level: 0,
332
+ level: {
333
+ _id: "",
334
+ name: "",
335
+ },
332
336
  // category: "",
333
337
  block: null,
334
338
  status: "active",
@@ -457,13 +461,13 @@ const selectedBuilding = computed(() => {
457
461
  return buildings.value.find((b) => b.value === buildingUnit.value.building);
458
462
  });
459
463
 
460
- const buildingLevels = computed(() => {
461
- const levels = selectedBuilding.value?.levels ?? [];
462
- return levels.map((level: string) => ({
463
- title: level,
464
- value: level,
465
- }))
466
- });
464
+ // const buildingLevels = computed(() => {
465
+ // const levels = selectedBuilding.value?.levels ?? [];
466
+ // return levels.map((level: { name: string; _id: string }) => ({
467
+ // name: level.name,
468
+ // value: level._id,
469
+ // }))
470
+ // });
467
471
 
468
472
  const disable = ref(false);
469
473
 
@@ -500,7 +504,7 @@ async function submit() {
500
504
 
501
505
  await updateById(buildingUnit.value._id ?? "", {
502
506
  name: buildingUnit.value.name,
503
- level: buildingUnit.value.level,
507
+ level: buildingUnit.value.level._id,
504
508
  // category: buildingUnit.value.category,
505
509
  buildingUnitFiles: (buildingUnit.value.buildingUnitFiles as string[] || []).map((id) => ({ id, name: buildingUnitFilesNames.value[id] ?? "" })),
506
510
  companyName: buildingUnit.value.companyName,
@@ -195,20 +195,27 @@ const props = defineProps({
195
195
  const { authenticate } = useLocalAuth();
196
196
  authenticate();
197
197
 
198
- const headers = [
199
- {
200
- title: "Date",
201
- value: "createdAt",
202
- },
203
- {
204
- title: "E-mail",
205
- value: "email",
206
- },
207
- {
208
- title: "Action",
209
- value: "action-table",
210
- },
211
- ];
198
+ const headers = computed(() => {
199
+ const baseHeaders = [
200
+ {
201
+ title: "Date",
202
+ value: "createdAt",
203
+ },
204
+ {
205
+ title: "E-mail",
206
+ value: "email",
207
+ },
208
+ ];
209
+
210
+ if (props.status === "pending" && props.cancelInvitation) {
211
+ baseHeaders.push({
212
+ title: "Action",
213
+ value: "action-table",
214
+ });
215
+ }
216
+
217
+ return baseHeaders;
218
+ });
212
219
 
213
220
  const { getVerifications: _getVerifications, cancelUserInvitation } =
214
221
  useVerification();
@@ -239,16 +246,21 @@ const {
239
246
  items: TMiniVerification[];
240
247
  pages: number;
241
248
  pageRange: string;
242
- }>("get-verifications" + props.status, () =>
243
- _getVerifications({
244
- page: page.value,
245
- status: props.status,
246
- search: headerSearch.value,
247
- type: "user-invite,member-invite",
248
- app: props.app,
249
- orgId: props.org,
250
- siteId: props.siteId,
251
- })
249
+ }>(
250
+ `get-verifications-${props.app}-${props.org}-${props.siteId}-${props.status}`,
251
+ () =>
252
+ _getVerifications({
253
+ page: page.value,
254
+ status: props.status,
255
+ search: headerSearch.value,
256
+ type: "user-invite,member-invite",
257
+ app: props.app,
258
+ orgId: props.org,
259
+ siteId: props.siteId,
260
+ }),
261
+ {
262
+ watch: [() => props.status]
263
+ }
252
264
  );
253
265
 
254
266
  const loading = computed(() => getVerificationsStatus.value === "pending");
@@ -261,7 +273,8 @@ watchEffect(() => {
261
273
  }
262
274
  });
263
275
 
264
- watch([headerSearch], () => {
276
+ watch([headerSearch, () => props.status], () => {
277
+ page.value = 1;
265
278
  getVerifications();
266
279
  });
267
280
 
@@ -159,8 +159,8 @@
159
159
  @click="handleUpdateMemberStatus"
160
160
  :loading="updateLoading"
161
161
  >
162
- {{ updateActionText }} Member
163
- </v-btn>
162
+ {{ updateActionText }} Member </v-btn
163
+ >r
164
164
  </template>
165
165
  </ConfirmDialog>
166
166
 
@@ -375,7 +375,7 @@ const {
375
375
  refresh: getAll,
376
376
  status: getAllReqStatus,
377
377
  } = useAsyncData(
378
- () => `get-all-members-${props.status}-${props.orgId}`,
378
+ `get-all-members-${props.type}-${props.orgId}-${props.siteId}-${props.status}`,
379
379
  () =>
380
380
  _getAll({
381
381
  status: props.status,
@@ -383,14 +383,23 @@ const {
383
383
  search: headerSearch.value,
384
384
  page: page.value,
385
385
  type: props.type,
386
+ siteId: props.siteId,
386
387
  }),
387
388
  {
388
- watch: [() => props.status, headerSearch],
389
+ watch: [() => props.status, () => props.orgId, () => props.siteId, headerSearch],
389
390
  }
390
391
  );
391
392
 
392
393
  const loading = computed(() => getAllReqStatus.value === "pending");
393
394
 
395
+ watch(headerSearch, () => {
396
+ page.value = 1;
397
+ });
398
+
399
+ watch([() => props.orgId, () => props.siteId], () => {
400
+ page.value = 1;
401
+ });
402
+
394
403
  watchEffect(() => {
395
404
  if (getAllReq.value) {
396
405
  items.value = getAllReq.value.items;
@@ -425,7 +434,7 @@ function setMember({
425
434
 
426
435
  const roles = ref<Array<Record<string, any>>>([]);
427
436
  const { getRoles } = useRole();
428
- const { data: getAllRoleReq } = useLazyAsyncData("get-roles", () =>
437
+ const { data: getAllRoleReq } = useLazyAsyncData(`get-roles-${props.type}-${props.orgId}`, () =>
429
438
  getRoles({ org: props.orgId, type: props.type, limit: 20 })
430
439
  );
431
440
 
@@ -267,7 +267,7 @@ const { create: _add, updateById: _update, getAll: _getAll } = useOnlineFormConf
267
267
 
268
268
  const { data: existingFormsData } = useLazyAsyncData(
269
269
  `online-form-configurations-filter-${siteId}-${Date.now()}`,
270
- () => _getAll({ site: siteId, org: orgId, limit: 100 })
270
+ () => _getAll({ site: siteId, org: orgId, status: "active", limit: 100 })
271
271
  );
272
272
 
273
273
  const availableTemplateNames = computed(() => {