@iservice365/layer-common 1.0.7 → 1.0.8
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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</v-row>
|
|
9
9
|
</v-toolbar>
|
|
10
10
|
<v-card-text style="max-height: 100vh; overflow-y: auto">
|
|
11
|
-
<v-form v-model="validForm" :disabled="disable">
|
|
11
|
+
<v-form v-model="validForm" ref="form" :disabled="disable">
|
|
12
12
|
<v-row no-gutters>
|
|
13
13
|
<v-col cols="12" class="mt-2">
|
|
14
14
|
<v-row no-gutters>
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
density="comfortable"
|
|
33
33
|
:rules="[requiredRule]"
|
|
34
34
|
:items="apps"
|
|
35
|
+
@update:model-value="handleUpdateApp"
|
|
35
36
|
></v-autocomplete>
|
|
36
37
|
</v-col>
|
|
37
38
|
</v-row>
|
|
@@ -46,12 +47,28 @@
|
|
|
46
47
|
:items="roles"
|
|
47
48
|
item-title="name"
|
|
48
49
|
item-value="_id"
|
|
50
|
+
:rules="[requiredRule]"
|
|
49
51
|
density="comfortable"
|
|
50
52
|
></v-autocomplete>
|
|
51
53
|
</v-col>
|
|
52
54
|
</v-row>
|
|
53
55
|
</v-col>
|
|
54
56
|
|
|
57
|
+
|
|
58
|
+
<v-col v-if="hasSite" cols="12">
|
|
59
|
+
<v-row no-gutters>
|
|
60
|
+
<InputLabel class="text-capitalize" title="Site" />
|
|
61
|
+
<v-col cols="12">
|
|
62
|
+
<v-autocomplete
|
|
63
|
+
v-model="invite.site"
|
|
64
|
+
:items="sites"
|
|
65
|
+
density="comfortable"
|
|
66
|
+
:rules="[requiredRule]"
|
|
67
|
+
></v-autocomplete>
|
|
68
|
+
</v-col>
|
|
69
|
+
</v-row>
|
|
70
|
+
</v-col>
|
|
71
|
+
|
|
55
72
|
<v-col cols="12" class="mt-2">
|
|
56
73
|
<v-checkbox v-model="createMore" density="comfortable" hide-details>
|
|
57
74
|
<template #label>
|
|
@@ -101,6 +118,7 @@
|
|
|
101
118
|
class="text-none"
|
|
102
119
|
size="48"
|
|
103
120
|
:disabled="!validForm"
|
|
121
|
+
:loading="submitting"
|
|
104
122
|
@click="submit"
|
|
105
123
|
>
|
|
106
124
|
Submit
|
|
@@ -126,9 +144,9 @@ const props = defineProps({
|
|
|
126
144
|
type: Object,
|
|
127
145
|
default: () => ({}),
|
|
128
146
|
},
|
|
129
|
-
|
|
147
|
+
app: {
|
|
130
148
|
type: String,
|
|
131
|
-
default: "
|
|
149
|
+
default: "organization",
|
|
132
150
|
},
|
|
133
151
|
org: {
|
|
134
152
|
type: String,
|
|
@@ -156,16 +174,20 @@ const props = defineProps({
|
|
|
156
174
|
const emit = defineEmits(["cancel", "success", "success:create-more"]);
|
|
157
175
|
|
|
158
176
|
const validForm = ref(false);
|
|
177
|
+
const form = ref<HTMLFormElement | null>(null)
|
|
159
178
|
const app = computed(() => useRuntimeConfig().public.APP ?? "");
|
|
179
|
+
const submitting = ref(false);
|
|
160
180
|
|
|
161
181
|
const invite = ref<Record<string, any>>({
|
|
162
182
|
email: "",
|
|
163
|
-
app: "
|
|
183
|
+
app: "",
|
|
164
184
|
role: "",
|
|
165
185
|
org: "",
|
|
186
|
+
site: "",
|
|
187
|
+
siteName: "",
|
|
166
188
|
});
|
|
167
189
|
|
|
168
|
-
invite.value.app = app
|
|
190
|
+
invite.value.app = props.app;
|
|
169
191
|
invite.value.org = props.org ?? "";
|
|
170
192
|
|
|
171
193
|
if (props.mode === "edit") {
|
|
@@ -177,16 +199,65 @@ if (props.mode === "edit") {
|
|
|
177
199
|
const { natureOfBusiness } = useLocal();
|
|
178
200
|
|
|
179
201
|
const apps = computed(() => {
|
|
180
|
-
const items =
|
|
202
|
+
const items = [];
|
|
181
203
|
items.unshift({ title: "Organization", value: "organization" });
|
|
204
|
+
|
|
205
|
+
if (props.app === "security_agency") {
|
|
206
|
+
items.push({ title: "Security Agency", value: "security_agency" });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (props.app === "cleaning_agency") {
|
|
210
|
+
items.push({ title: "Cleaning Agency", value: "cleaning_agency" });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (props.app === "property_manager") {
|
|
214
|
+
items.push({ title: "Property Manager", value: "property_manager" });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (props.app === "mechanical_electrical_services") {
|
|
218
|
+
items.push({
|
|
219
|
+
title: "Mechanical & Electrical Services",
|
|
220
|
+
value: "mechanical_electrical_services",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
182
224
|
return items;
|
|
183
225
|
});
|
|
184
226
|
|
|
227
|
+
const hasSite = computed(() => {
|
|
228
|
+
return natureOfBusiness.map((i) => i.value).includes(invite.value.app);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const sites = ref<Array<Record<string, any>>>([]);
|
|
232
|
+
|
|
233
|
+
const { getAll: getAllCustomerSite } = useCustomerSite();
|
|
234
|
+
|
|
235
|
+
const { data: siteData, refresh: refreshSiteData } = await useLazyAsyncData(
|
|
236
|
+
"get-sites-by-org",
|
|
237
|
+
async () => await getAllCustomerSite({ org: props.org, limit: 50 }),
|
|
238
|
+
{ }
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
watchEffect(() => {
|
|
242
|
+
if (siteData.value) {
|
|
243
|
+
sites.value = siteData.value.items.map((i: any) => ({
|
|
244
|
+
title: i.name,
|
|
245
|
+
value: i.site,
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
watchEffect(() => {
|
|
251
|
+
if (hasSite.value) {
|
|
252
|
+
refreshSiteData();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
185
256
|
const roles = ref<Array<Record<string, any>>>([]);
|
|
186
257
|
|
|
187
258
|
const { getRoles } = useRole();
|
|
188
259
|
|
|
189
|
-
const { data: RolesData } = await useLazyAsyncData(
|
|
260
|
+
const { data: RolesData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
190
261
|
"get-roles-by-type",
|
|
191
262
|
() => getRoles({ org: props.org, type: app.value, limit: 50 }),
|
|
192
263
|
{ watch: [app] }
|
|
@@ -198,12 +269,12 @@ watchEffect(() => {
|
|
|
198
269
|
}
|
|
199
270
|
});
|
|
200
271
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
272
|
+
function handleUpdateApp(value: string){
|
|
273
|
+
invite.value.role = "";
|
|
274
|
+
invite.value.site = "";
|
|
275
|
+
refreshRoles();
|
|
276
|
+
}
|
|
277
|
+
|
|
207
278
|
|
|
208
279
|
const createMore = ref(false);
|
|
209
280
|
const disable = ref(false);
|
|
@@ -222,15 +293,19 @@ function resetInvite() {
|
|
|
222
293
|
const { inviteUser } = useUser();
|
|
223
294
|
|
|
224
295
|
async function submit() {
|
|
296
|
+
submitting.value = true;
|
|
225
297
|
try {
|
|
226
298
|
await inviteUser(invite.value);
|
|
227
|
-
emit("success");
|
|
228
299
|
|
|
229
300
|
if (createMore.value) {
|
|
301
|
+
form.value?.reset();
|
|
230
302
|
resetInvite();
|
|
231
|
-
|
|
303
|
+
emit("success", false);
|
|
304
|
+
} else emit("success", true);
|
|
232
305
|
} catch (error: any) {
|
|
233
306
|
message.value = error.response._data.message;
|
|
307
|
+
} finally {
|
|
308
|
+
submitting.value = false;
|
|
234
309
|
}
|
|
235
310
|
}
|
|
236
311
|
|
|
@@ -142,7 +142,9 @@
|
|
|
142
142
|
title="Invite member"
|
|
143
143
|
:org="org"
|
|
144
144
|
@cancel="dialogMember = false"
|
|
145
|
+
@success="handleSuccess"
|
|
145
146
|
@invited="getVerifications()"
|
|
147
|
+
:app="props.app"
|
|
146
148
|
/>
|
|
147
149
|
</v-dialog>
|
|
148
150
|
</v-row>
|
|
@@ -150,6 +152,10 @@
|
|
|
150
152
|
|
|
151
153
|
<script setup lang="ts">
|
|
152
154
|
const props = defineProps({
|
|
155
|
+
app: {
|
|
156
|
+
type: String,
|
|
157
|
+
default: "organization",
|
|
158
|
+
},
|
|
153
159
|
route: {
|
|
154
160
|
type: String,
|
|
155
161
|
default: "index",
|
|
@@ -282,6 +288,13 @@ async function onConfirmCancel() {
|
|
|
282
288
|
cancelLoading.value = false;
|
|
283
289
|
}
|
|
284
290
|
|
|
291
|
+
function handleSuccess(closeForm: boolean) {
|
|
292
|
+
getVerifications();
|
|
293
|
+
if (closeForm) {
|
|
294
|
+
dialogMember.value = false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
285
298
|
watchEffect(() => {
|
|
286
299
|
if (!props.viewInvitations) {
|
|
287
300
|
useRouter().back();
|
package/middleware/02.org.ts
CHANGED
|
@@ -4,12 +4,12 @@ const hexSchema = z
|
|
|
4
4
|
.string()
|
|
5
5
|
.regex(/^[0-9a-fA-F]{24}$/, "Invalid organization ID");
|
|
6
6
|
|
|
7
|
-
export default defineNuxtRouteMiddleware(async (to) => {
|
|
7
|
+
export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
8
8
|
if (import.meta.server) return;
|
|
9
9
|
|
|
10
10
|
const { organization, org } = to.params;
|
|
11
11
|
|
|
12
|
-
if (!hexSchema.safeParse(organization
|
|
12
|
+
if (!hexSchema.safeParse(organization || org).success) {
|
|
13
13
|
return navigateTo(
|
|
14
14
|
{ name: "require-organization-membership" },
|
|
15
15
|
{ replace: true }
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default defineNuxtPlugin(() => {
|
|
|
6
6
|
|
|
7
7
|
const { userAppRole, id, orgNature } = useLocalSetup();
|
|
8
8
|
|
|
9
|
-
router.afterEach((to) => {
|
|
9
|
+
router.afterEach(async (to) => {
|
|
10
10
|
const isMember = to.meta?.memberOnly;
|
|
11
11
|
|
|
12
12
|
if (!isMember) return;
|
|
@@ -19,11 +19,12 @@ export default defineNuxtPlugin(() => {
|
|
|
19
19
|
|
|
20
20
|
const userId = computed(() => useCookie("user").value ?? "");
|
|
21
21
|
|
|
22
|
-
const { data: userMemberData, error: userMemberError } =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const { data: userMemberData, error: userMemberError } =
|
|
23
|
+
await useLazyAsyncData(
|
|
24
|
+
"get-member-by-id",
|
|
25
|
+
() => getByUserType(userId.value, APP, org.value),
|
|
26
|
+
{ watch: [userId] }
|
|
27
|
+
);
|
|
27
28
|
|
|
28
29
|
watchEffect(() => {
|
|
29
30
|
if (userMemberError.value) {
|
|
@@ -42,7 +43,7 @@ export default defineNuxtPlugin(() => {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
|
|
45
|
-
const { data: getOrgByIdReq } = useLazyAsyncData(
|
|
46
|
+
const { data: getOrgByIdReq } = await useLazyAsyncData(
|
|
46
47
|
"get-org-by-id",
|
|
47
48
|
() => getById(org.value),
|
|
48
49
|
{ watch: [org] }
|
|
@@ -56,7 +57,7 @@ export default defineNuxtPlugin(() => {
|
|
|
56
57
|
|
|
57
58
|
const roleId = computed(() => userMemberData.value?.role ?? "");
|
|
58
59
|
|
|
59
|
-
const { data: getRoleByIdReq } = useLazyAsyncData(
|
|
60
|
+
const { data: getRoleByIdReq } = await useLazyAsyncData(
|
|
60
61
|
"get-role-by-id",
|
|
61
62
|
() => getRoleById(roleId.value),
|
|
62
63
|
{ watch: [roleId], immediate: false }
|