@goweekdays/layer-common 1.0.1 → 1.0.3
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/.playground/nuxt.config.ts +0 -1
- package/CHANGELOG.md +12 -0
- package/components/InvitationMain.vue +195 -0
- package/components/Layout/Header.vue +14 -5
- package/components/LinkHome.vue +9 -0
- package/components/MemberMain.vue +452 -0
- package/components/RolePermissionMain.vue +1 -1
- package/composables/useCommonPermission.ts +61 -2
- package/composables/useLocal.ts +3 -28
- package/composables/useLocalAuth.ts +4 -0
- package/composables/useLocalSetup.ts +46 -0
- package/composables/useMember.ts +80 -59
- package/composables/useOrg.ts +12 -1
- package/composables/useUser.ts +9 -2
- package/composables/useUtils.ts +27 -0
- package/composables/useVerification.ts +3 -2
- package/nuxt.config.ts +1 -4
- package/package.json +2 -1
- package/plugins/iconify.client.ts +5 -0
- package/plugins/vuetify.ts +10 -0
- package/types/role.d.ts +1 -1
- package/composables/useAdminPermission.ts +0 -127
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-row no-gutters>
|
|
3
|
+
<v-col v-if="props.seatManagement !== 'index'" cols="12" class="mb-2">
|
|
4
|
+
<v-row no-gutters>
|
|
5
|
+
<v-btn
|
|
6
|
+
class="text-none"
|
|
7
|
+
rounded="pill"
|
|
8
|
+
variant="tonal"
|
|
9
|
+
:to="{
|
|
10
|
+
name: props.seatManagement,
|
|
11
|
+
params: { organization: props.orgId },
|
|
12
|
+
}"
|
|
13
|
+
size="large"
|
|
14
|
+
>
|
|
15
|
+
Manage seats
|
|
16
|
+
</v-btn>
|
|
17
|
+
</v-row>
|
|
18
|
+
</v-col>
|
|
19
|
+
|
|
20
|
+
<v-col cols="12">
|
|
21
|
+
<v-card width="100%" variant="outlined" border="thin" rounded="lg">
|
|
22
|
+
<v-toolbar density="compact" color="grey-lighten-4">
|
|
23
|
+
<template #prepend>
|
|
24
|
+
<v-btn fab icon density="comfortable" @click="getAll()">
|
|
25
|
+
<v-icon>mdi-refresh</v-icon>
|
|
26
|
+
</v-btn>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<template #append>
|
|
30
|
+
<v-row no-gutters justify="end" align="center">
|
|
31
|
+
<span class="mr-2 text-caption text-font gray">
|
|
32
|
+
{{ pageRange }}
|
|
33
|
+
</span>
|
|
34
|
+
<local-pagination
|
|
35
|
+
v-model="page"
|
|
36
|
+
:length="pages"
|
|
37
|
+
@update:value="getAll()"
|
|
38
|
+
/>
|
|
39
|
+
</v-row>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<template #extension>
|
|
43
|
+
<v-tabs>
|
|
44
|
+
<v-tab
|
|
45
|
+
v-for="tab in [
|
|
46
|
+
{ name: 'Active', status: 'active' },
|
|
47
|
+
{ name: 'Suspended', status: 'suspended' },
|
|
48
|
+
]"
|
|
49
|
+
:key="tab.status"
|
|
50
|
+
:to="{
|
|
51
|
+
name: props.route,
|
|
52
|
+
params: setRouteParams({
|
|
53
|
+
status: tab.status,
|
|
54
|
+
organization: props.orgId,
|
|
55
|
+
}),
|
|
56
|
+
}"
|
|
57
|
+
>
|
|
58
|
+
{{ tab.name }}
|
|
59
|
+
</v-tab>
|
|
60
|
+
</v-tabs>
|
|
61
|
+
</template>
|
|
62
|
+
</v-toolbar>
|
|
63
|
+
|
|
64
|
+
<v-data-table
|
|
65
|
+
:headers="props.headers"
|
|
66
|
+
:items="items"
|
|
67
|
+
item-value="_id"
|
|
68
|
+
items-per-page="20"
|
|
69
|
+
fixed-header
|
|
70
|
+
hide-default-footer
|
|
71
|
+
style="max-height: calc(100vh - (126px))"
|
|
72
|
+
:loading="loading"
|
|
73
|
+
>
|
|
74
|
+
<template #item.nature="{ item }">
|
|
75
|
+
{{ replaceMatch(item.nature, "_", " ") }}
|
|
76
|
+
</template>
|
|
77
|
+
<template #item.action-table="{ item }">
|
|
78
|
+
<v-menu
|
|
79
|
+
v-if="
|
|
80
|
+
(status === 'active' &&
|
|
81
|
+
(canSuspendMembers || canDeleteMembers)) ||
|
|
82
|
+
(status === 'suspended' &&
|
|
83
|
+
(canActivateMembers || canDeleteMembers))
|
|
84
|
+
"
|
|
85
|
+
v-model="item.menuOpen"
|
|
86
|
+
offset-y
|
|
87
|
+
width="150"
|
|
88
|
+
>
|
|
89
|
+
<template v-slot:activator="{ props }">
|
|
90
|
+
<v-icon v-bind="props">mdi-dots-horizontal</v-icon>
|
|
91
|
+
</template>
|
|
92
|
+
<v-list>
|
|
93
|
+
<v-list-item
|
|
94
|
+
v-if="props.assignRole"
|
|
95
|
+
@click="
|
|
96
|
+
setMember({
|
|
97
|
+
dialog: true,
|
|
98
|
+
mode: 'assign-role',
|
|
99
|
+
role: item,
|
|
100
|
+
})
|
|
101
|
+
"
|
|
102
|
+
>
|
|
103
|
+
Assign Role
|
|
104
|
+
</v-list-item>
|
|
105
|
+
|
|
106
|
+
<v-list-item
|
|
107
|
+
v-if="status === 'active' && canSuspendMembers"
|
|
108
|
+
@click="openUpdateDialog(item.user, 'suspended')"
|
|
109
|
+
>
|
|
110
|
+
Suspend
|
|
111
|
+
</v-list-item>
|
|
112
|
+
<v-list-item
|
|
113
|
+
v-if="status === 'suspended' && canActivateMembers"
|
|
114
|
+
@click="openUpdateDialog(item.user, 'active')"
|
|
115
|
+
>
|
|
116
|
+
Activate
|
|
117
|
+
</v-list-item>
|
|
118
|
+
<v-list-item
|
|
119
|
+
v-if="canDeleteMembers"
|
|
120
|
+
@click="openUpdateDialog(item.user, 'deleted')"
|
|
121
|
+
>
|
|
122
|
+
Delete
|
|
123
|
+
</v-list-item>
|
|
124
|
+
</v-list>
|
|
125
|
+
</v-menu>
|
|
126
|
+
</template>
|
|
127
|
+
</v-data-table>
|
|
128
|
+
</v-card>
|
|
129
|
+
</v-col>
|
|
130
|
+
<ConfirmDialog
|
|
131
|
+
v-model="confirmDialog"
|
|
132
|
+
:loading="updateLoading"
|
|
133
|
+
@submit="handleUpdateMemberStatus"
|
|
134
|
+
>
|
|
135
|
+
<template #title>
|
|
136
|
+
<span class="font-weight-medium text-h5">
|
|
137
|
+
{{ updateActionText }} Member</span
|
|
138
|
+
>
|
|
139
|
+
</template>
|
|
140
|
+
|
|
141
|
+
<template #description>
|
|
142
|
+
<p class="text-subtitle-2">
|
|
143
|
+
Are you sure you want to {{ updateActionText }} this Member? This
|
|
144
|
+
action cannot be undone.
|
|
145
|
+
</p>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<template #footer>
|
|
149
|
+
<v-btn
|
|
150
|
+
variant="text"
|
|
151
|
+
@click="confirmDialog = false"
|
|
152
|
+
:disabled="updateLoading"
|
|
153
|
+
>
|
|
154
|
+
Close
|
|
155
|
+
</v-btn>
|
|
156
|
+
<v-btn
|
|
157
|
+
color="primary"
|
|
158
|
+
variant="flat"
|
|
159
|
+
@click="handleUpdateMemberStatus"
|
|
160
|
+
:loading="updateLoading"
|
|
161
|
+
>
|
|
162
|
+
{{ updateActionText }} Member
|
|
163
|
+
</v-btn>
|
|
164
|
+
</template>
|
|
165
|
+
</ConfirmDialog>
|
|
166
|
+
|
|
167
|
+
<Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
|
|
168
|
+
|
|
169
|
+
<v-dialog v-model="assignRoleDialog" max-width="400px">
|
|
170
|
+
<v-card>
|
|
171
|
+
<v-card-title class="text-h5">Assign Role</v-card-title>
|
|
172
|
+
<v-card-text>
|
|
173
|
+
<v-form v-model="memberRoleForm" @submit.prevent="updateMemberRole()">
|
|
174
|
+
<v-row no-gutters>
|
|
175
|
+
<v-col cols="12" class="mb-2">
|
|
176
|
+
<v-row no-gutters>
|
|
177
|
+
<InputLabel class="text-capitalize" title="Name" required />
|
|
178
|
+
<v-col cols="12">
|
|
179
|
+
<v-select
|
|
180
|
+
v-model="selectedRole"
|
|
181
|
+
:items="roles"
|
|
182
|
+
item-value="_id"
|
|
183
|
+
item-title="name"
|
|
184
|
+
density="comfortable"
|
|
185
|
+
:rules="[requiredRule]"
|
|
186
|
+
:error-messages="
|
|
187
|
+
selectedRole === selectedMemberRole
|
|
188
|
+
? 'Role already assigned'
|
|
189
|
+
: ''
|
|
190
|
+
"
|
|
191
|
+
persistent-hint
|
|
192
|
+
></v-select>
|
|
193
|
+
</v-col>
|
|
194
|
+
|
|
195
|
+
<v-col cols="12" class="text-error text-center">
|
|
196
|
+
{{ message }}
|
|
197
|
+
</v-col>
|
|
198
|
+
</v-row>
|
|
199
|
+
</v-col>
|
|
200
|
+
|
|
201
|
+
<v-col cols="12">
|
|
202
|
+
<v-row>
|
|
203
|
+
<v-col cols="6">
|
|
204
|
+
<v-btn
|
|
205
|
+
block
|
|
206
|
+
variant="text"
|
|
207
|
+
@click="setMember({ mode: 'assign-role' })"
|
|
208
|
+
>
|
|
209
|
+
Cancel
|
|
210
|
+
</v-btn>
|
|
211
|
+
</v-col>
|
|
212
|
+
<v-col cols="6">
|
|
213
|
+
<v-btn
|
|
214
|
+
block
|
|
215
|
+
variant="flat"
|
|
216
|
+
color="black"
|
|
217
|
+
:disabled="!memberRoleForm"
|
|
218
|
+
type="submit"
|
|
219
|
+
>
|
|
220
|
+
Submit
|
|
221
|
+
</v-btn>
|
|
222
|
+
</v-col>
|
|
223
|
+
</v-row>
|
|
224
|
+
</v-col>
|
|
225
|
+
</v-row>
|
|
226
|
+
</v-form>
|
|
227
|
+
</v-card-text>
|
|
228
|
+
</v-card>
|
|
229
|
+
</v-dialog>
|
|
230
|
+
</v-row>
|
|
231
|
+
</template>
|
|
232
|
+
|
|
233
|
+
<script setup lang="ts">
|
|
234
|
+
const props = defineProps({
|
|
235
|
+
orgId: {
|
|
236
|
+
type: String,
|
|
237
|
+
default: "",
|
|
238
|
+
},
|
|
239
|
+
customerId: {
|
|
240
|
+
type: String,
|
|
241
|
+
default: "",
|
|
242
|
+
},
|
|
243
|
+
siteId: {
|
|
244
|
+
type: String,
|
|
245
|
+
default: "",
|
|
246
|
+
},
|
|
247
|
+
status: {
|
|
248
|
+
type: String,
|
|
249
|
+
default: "active",
|
|
250
|
+
},
|
|
251
|
+
type: {
|
|
252
|
+
type: String,
|
|
253
|
+
default: "organization",
|
|
254
|
+
},
|
|
255
|
+
seatManagement: {
|
|
256
|
+
type: String,
|
|
257
|
+
default: "index",
|
|
258
|
+
},
|
|
259
|
+
inviteMember: {
|
|
260
|
+
type: String,
|
|
261
|
+
default: "index",
|
|
262
|
+
},
|
|
263
|
+
route: {
|
|
264
|
+
type: String,
|
|
265
|
+
default: "index",
|
|
266
|
+
},
|
|
267
|
+
canActivateMembers: {
|
|
268
|
+
type: Boolean,
|
|
269
|
+
default: false,
|
|
270
|
+
},
|
|
271
|
+
canSuspendMembers: {
|
|
272
|
+
type: Boolean,
|
|
273
|
+
default: false,
|
|
274
|
+
},
|
|
275
|
+
canDeleteMembers: {
|
|
276
|
+
type: Boolean,
|
|
277
|
+
default: false,
|
|
278
|
+
},
|
|
279
|
+
assignRole: {
|
|
280
|
+
type: Boolean,
|
|
281
|
+
default: false,
|
|
282
|
+
},
|
|
283
|
+
headers: {
|
|
284
|
+
type: Array as PropType<Array<Record<string, string>>>,
|
|
285
|
+
default: () => [
|
|
286
|
+
{
|
|
287
|
+
title: "Name",
|
|
288
|
+
|
|
289
|
+
value: "name",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
title: "Role",
|
|
293
|
+
|
|
294
|
+
value: "roleName",
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
title: "Organization",
|
|
298
|
+
|
|
299
|
+
value: "orgName",
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
title: "Action",
|
|
303
|
+
value: "action-table",
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
310
|
+
const page = ref(1);
|
|
311
|
+
const pages = ref(10);
|
|
312
|
+
const pageRange = ref("-- - -- of --");
|
|
313
|
+
|
|
314
|
+
const message = ref("");
|
|
315
|
+
const messageSnackbar = ref(false);
|
|
316
|
+
const messageColor = ref("");
|
|
317
|
+
|
|
318
|
+
const {
|
|
319
|
+
getAll: _getAll,
|
|
320
|
+
updateMemberStatus: _updateMemberStatus,
|
|
321
|
+
updateMemberRole: _updateMemberRole,
|
|
322
|
+
} = useMember();
|
|
323
|
+
|
|
324
|
+
const { headerSearch } = useLocal();
|
|
325
|
+
const { replaceMatch, setRouteParams, requiredRule } = useUtils();
|
|
326
|
+
|
|
327
|
+
const {
|
|
328
|
+
data: getAllReq,
|
|
329
|
+
refresh: getAll,
|
|
330
|
+
status: getAllReqStatus,
|
|
331
|
+
} = useLazyAsyncData("get-all-members-by-status" + props.status, () =>
|
|
332
|
+
_getAll({
|
|
333
|
+
status: props.status,
|
|
334
|
+
org: props.orgId,
|
|
335
|
+
search: headerSearch.value,
|
|
336
|
+
page: page.value,
|
|
337
|
+
type: props.type,
|
|
338
|
+
})
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
const loading = computed(() => getAllReqStatus.value === "pending");
|
|
342
|
+
|
|
343
|
+
watchEffect(() => {
|
|
344
|
+
if (getAllReq.value) {
|
|
345
|
+
items.value = getAllReq.value.items;
|
|
346
|
+
pages.value = getAllReq.value.pages;
|
|
347
|
+
pageRange.value = getAllReq.value.pageRange;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
watch(headerSearch, () => {
|
|
352
|
+
getAll();
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const confirmDialog = ref(false);
|
|
356
|
+
const selectedMemberId = ref<string | null>(null);
|
|
357
|
+
const updateLoading = ref(false);
|
|
358
|
+
const updateAction = ref("");
|
|
359
|
+
|
|
360
|
+
const memberRoleForm = ref(false);
|
|
361
|
+
const assignRoleDialog = ref(false);
|
|
362
|
+
const selectedRole = ref<string | null>(null);
|
|
363
|
+
const selectedMemberRole = ref("");
|
|
364
|
+
|
|
365
|
+
function setMember({
|
|
366
|
+
dialog = false,
|
|
367
|
+
mode = "",
|
|
368
|
+
role = {} as Record<string, any>,
|
|
369
|
+
} = {}) {
|
|
370
|
+
if (mode === "assign-role") {
|
|
371
|
+
assignRoleDialog.value = dialog;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
selectedMemberId.value = role._id;
|
|
375
|
+
selectedRole.value = role.role;
|
|
376
|
+
selectedMemberRole.value = role.role;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const roles = ref<Array<Record<string, any>>>([]);
|
|
380
|
+
const { getRoles } = useRole();
|
|
381
|
+
const { data: getAllRoleReq } = useLazyAsyncData("get-roles", () =>
|
|
382
|
+
getRoles({ org: props.orgId, type: props.type, limit: 20 })
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
watchEffect(() => {
|
|
386
|
+
if (getAllRoleReq.value) {
|
|
387
|
+
roles.value = getAllRoleReq.value.items;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
watchEffect(() => {
|
|
392
|
+
if (selectedRole.value) {
|
|
393
|
+
message.value = "";
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
async function updateMemberRole() {
|
|
398
|
+
try {
|
|
399
|
+
await _updateMemberRole(
|
|
400
|
+
selectedMemberId.value ?? "",
|
|
401
|
+
selectedRole.value ?? "",
|
|
402
|
+
props.type,
|
|
403
|
+
props.orgId
|
|
404
|
+
);
|
|
405
|
+
await setMember({ mode: "assign-role" });
|
|
406
|
+
await getAll();
|
|
407
|
+
} catch (error: any) {
|
|
408
|
+
message.value = error?.response?._data?.message || "Failed to update role";
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function openUpdateDialog(id: string, action: string) {
|
|
413
|
+
updateAction.value = action;
|
|
414
|
+
selectedMemberId.value = id;
|
|
415
|
+
confirmDialog.value = true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function showMessage(msg: string, color: string) {
|
|
419
|
+
message.value = msg;
|
|
420
|
+
messageColor.value = color;
|
|
421
|
+
messageSnackbar.value = true;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async function handleUpdateMemberStatus() {
|
|
425
|
+
if (!selectedMemberId.value) return;
|
|
426
|
+
updateLoading.value = true;
|
|
427
|
+
try {
|
|
428
|
+
const res = await _updateMemberStatus(
|
|
429
|
+
selectedMemberId.value,
|
|
430
|
+
updateAction.value
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
confirmDialog.value = false;
|
|
434
|
+
showMessage(res.message, "success");
|
|
435
|
+
getAll();
|
|
436
|
+
} catch (error: any) {
|
|
437
|
+
const errorMessage = error?.response?._data?.message;
|
|
438
|
+
showMessage(errorMessage, "error");
|
|
439
|
+
} finally {
|
|
440
|
+
updateLoading.value = false;
|
|
441
|
+
selectedMemberId.value = null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const updateActionText = computed(() => {
|
|
445
|
+
const map: Record<string, string> = {
|
|
446
|
+
active: "Activate",
|
|
447
|
+
suspended: "Suspend",
|
|
448
|
+
deleted: "Delete",
|
|
449
|
+
};
|
|
450
|
+
return map[updateAction.value] || updateAction.value;
|
|
451
|
+
});
|
|
452
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function useCommonPermissions() {
|
|
2
|
-
const
|
|
2
|
+
const invitationPermissions: Record<string, TPermission> = {
|
|
3
3
|
"create-invitation": {
|
|
4
4
|
check: true,
|
|
5
5
|
description:
|
|
@@ -23,6 +23,11 @@ export function useCommonPermissions() {
|
|
|
23
23
|
description:
|
|
24
24
|
"Allows the user to view the list of all members in the organization.",
|
|
25
25
|
},
|
|
26
|
+
"assign-member-role": {
|
|
27
|
+
check: true,
|
|
28
|
+
description:
|
|
29
|
+
"Allows the user to assign a specific role to a member in the organization.",
|
|
30
|
+
},
|
|
26
31
|
"suspend-member": {
|
|
27
32
|
check: true,
|
|
28
33
|
description: "Allows the user to suspend a member's account temporarily.",
|
|
@@ -63,9 +68,63 @@ export function useCommonPermissions() {
|
|
|
63
68
|
},
|
|
64
69
|
};
|
|
65
70
|
|
|
71
|
+
const feedbackPermissions: Record<string, TPermission> = {
|
|
72
|
+
"add-feedback": {
|
|
73
|
+
check: true,
|
|
74
|
+
description: "Allows the user to create a new feedback.",
|
|
75
|
+
},
|
|
76
|
+
"see-all-feedback": {
|
|
77
|
+
check: true,
|
|
78
|
+
description: "Allows the user to view the list of all feedback.",
|
|
79
|
+
},
|
|
80
|
+
"see-feedback-details": {
|
|
81
|
+
check: true,
|
|
82
|
+
description:
|
|
83
|
+
"Allows the user to view the details of a specific feedback.",
|
|
84
|
+
},
|
|
85
|
+
"delete-feedback": {
|
|
86
|
+
check: true,
|
|
87
|
+
description:
|
|
88
|
+
"Allows the user to remove a feedback from the system permanently.",
|
|
89
|
+
},
|
|
90
|
+
"update-feedback": {
|
|
91
|
+
check: true,
|
|
92
|
+
description:
|
|
93
|
+
"Allows the user to update the details of an existing feedback.",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const workOrderPermissions: Record<string, TPermission> = {
|
|
98
|
+
"create-work-order": {
|
|
99
|
+
check: true,
|
|
100
|
+
description: "Allows the user to create a new work order.",
|
|
101
|
+
},
|
|
102
|
+
"see-all-work-orders": {
|
|
103
|
+
check: true,
|
|
104
|
+
description: "Allows the user to view the list of all work orders.",
|
|
105
|
+
},
|
|
106
|
+
"see-work-order-details": {
|
|
107
|
+
check: true,
|
|
108
|
+
description:
|
|
109
|
+
"Allows the user to view the details of a specific work order.",
|
|
110
|
+
},
|
|
111
|
+
"delete-work-order": {
|
|
112
|
+
check: true,
|
|
113
|
+
description:
|
|
114
|
+
"Allows the user to remove a work order from the system permanently.",
|
|
115
|
+
},
|
|
116
|
+
"update-work-order": {
|
|
117
|
+
check: true,
|
|
118
|
+
description:
|
|
119
|
+
"Allows the user to update the details of an existing work order.",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
66
123
|
return {
|
|
67
|
-
|
|
124
|
+
invitationPermissions,
|
|
68
125
|
memberPermissions,
|
|
69
126
|
rolePermissions,
|
|
127
|
+
feedbackPermissions,
|
|
128
|
+
workOrderPermissions,
|
|
70
129
|
};
|
|
71
130
|
}
|
package/composables/useLocal.ts
CHANGED
|
@@ -9,28 +9,15 @@ export default function useLocal() {
|
|
|
9
9
|
|
|
10
10
|
const drawer = useState("drawer", () => true);
|
|
11
11
|
|
|
12
|
-
const {
|
|
13
|
-
APP_INVENTORY,
|
|
14
|
-
APP_ASSET,
|
|
15
|
-
APP_BOOK_KEEPING,
|
|
16
|
-
APP_ACCOUNTING,
|
|
17
|
-
APP_ZONAL,
|
|
18
|
-
APP_SCHOOL,
|
|
19
|
-
} = appConfig;
|
|
12
|
+
const { APP_INVENTORY, APP_ASSET, APP_FINANCE } = appConfig;
|
|
20
13
|
const { currentOrg } = useOrg();
|
|
21
14
|
|
|
22
15
|
const apps = computed(() => {
|
|
23
16
|
return [
|
|
24
17
|
{
|
|
25
|
-
title: "
|
|
18
|
+
title: "Finance",
|
|
26
19
|
icon: "mdi-file-document-multiple",
|
|
27
|
-
link:
|
|
28
|
-
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
title: "Bookkeeping",
|
|
32
|
-
icon: "mdi-file-document-edit-outline",
|
|
33
|
-
link: APP_BOOK_KEEPING as string,
|
|
20
|
+
link: APP_FINANCE as string,
|
|
34
21
|
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
35
22
|
},
|
|
36
23
|
{
|
|
@@ -45,18 +32,6 @@ export default function useLocal() {
|
|
|
45
32
|
link: APP_ASSET as string,
|
|
46
33
|
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
47
34
|
},
|
|
48
|
-
{
|
|
49
|
-
title: "Zonal",
|
|
50
|
-
icon: "mdi-hospital-marker",
|
|
51
|
-
link: APP_ZONAL as string,
|
|
52
|
-
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
title: "School",
|
|
56
|
-
icon: "mdi-school",
|
|
57
|
-
link: APP_SCHOOL as string,
|
|
58
|
-
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
59
|
-
},
|
|
60
35
|
];
|
|
61
36
|
});
|
|
62
37
|
|
|
@@ -4,6 +4,10 @@ export default function useLocalAuth() {
|
|
|
4
4
|
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
5
5
|
|
|
6
6
|
function authenticate() {
|
|
7
|
+
if (currentUser.value) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
// Get access token from cookies
|
|
8
12
|
const accessToken = useCookie("accessToken", cookieConfig).value;
|
|
9
13
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function useLocalSetup(type: string, org?: string) {
|
|
2
|
+
const { currentUser } = useLocalAuth();
|
|
3
|
+
|
|
4
|
+
const userId = computed(() => currentUser.value?._id ?? "");
|
|
5
|
+
|
|
6
|
+
const { getByUserType } = useMember();
|
|
7
|
+
|
|
8
|
+
const { data: userMemberData, error: userMemberError } = useLazyAsyncData(
|
|
9
|
+
"get-member-by-id",
|
|
10
|
+
() => getByUserType(userId.value, type, org),
|
|
11
|
+
{ watch: [userId], immediate: false }
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
watchEffect(() => {
|
|
15
|
+
if (userMemberError.value) {
|
|
16
|
+
navigateTo({
|
|
17
|
+
name: "index",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { getRoleById } = useRole();
|
|
23
|
+
|
|
24
|
+
const roleId = computed(() => userMemberData.value?.role ?? "");
|
|
25
|
+
|
|
26
|
+
const userAppRole = useState<Record<string, any> | null>(
|
|
27
|
+
"userAppRole",
|
|
28
|
+
() => null
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const { data: getRoleByIdReq } = useLazyAsyncData(
|
|
32
|
+
"get-role-by-id",
|
|
33
|
+
() => getRoleById(roleId.value),
|
|
34
|
+
{ watch: [roleId], immediate: false }
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
watchEffect(() => {
|
|
38
|
+
if (getRoleByIdReq.value) {
|
|
39
|
+
userAppRole.value = getRoleByIdReq.value;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
userAppRole,
|
|
45
|
+
};
|
|
46
|
+
}
|