@goweekdays/layer-common 1.0.0 → 1.0.2
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/ConfirmDialog.vue +66 -0
- package/components/InvitationMain.vue +195 -0
- package/components/Layout/Header.vue +14 -5
- package/components/MemberMain.vue +452 -0
- package/components/RolePermissionFormCreate.vue +179 -0
- package/components/RolePermissionFormPreviewUpdate.vue +184 -0
- package/components/RolePermissionMain.vue +376 -0
- package/components/SwitchContext.vue +109 -0
- package/components/SwitchOrg.vue +10 -11
- package/composables/useCommonPermission.ts +130 -0
- package/composables/useLocal.ts +12 -21
- package/composables/useLocalAuth.ts +4 -22
- package/composables/useLocalSetup.ts +38 -0
- package/composables/useMember.ts +78 -60
- package/composables/useOrg.ts +36 -13
- package/composables/useOrgPermission.ts +27 -0
- package/composables/useRole.ts +5 -3
- package/composables/useSchoolPermission.ts +13 -0
- package/composables/useSubscription.ts +6 -2
- package/composables/useUser.ts +19 -12
- package/composables/useUtils.ts +46 -10
- package/composables/useVerification.ts +3 -2
- package/nuxt.config.ts +1 -3
- package/package.json +1 -1
- package/types/org.d.ts +1 -0
- package/types/role.d.ts +1 -0
- package/types/user.d.ts +3 -1
- package/composables/useAdminPermission.ts +0 -127
package/composables/useUser.ts
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
1
|
export default function useUser() {
|
|
2
|
-
function inviteUser({
|
|
3
|
-
|
|
2
|
+
function inviteUser({
|
|
3
|
+
email = "",
|
|
4
|
+
app = "",
|
|
5
|
+
role = "",
|
|
6
|
+
roleName = "",
|
|
7
|
+
org = "",
|
|
8
|
+
orgName = "",
|
|
9
|
+
} = {}) {
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>("/api/auth/invite", {
|
|
4
11
|
method: "POST",
|
|
5
|
-
body: { email, app, role,
|
|
12
|
+
body: { email, app, role, roleName, org, orgName },
|
|
6
13
|
});
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
function updateName({ firstName = "", lastName = "" } = {}) {
|
|
10
|
-
return useNuxtApp().$api<
|
|
17
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/name", {
|
|
11
18
|
method: "PUT",
|
|
12
19
|
body: { firstName, lastName },
|
|
13
20
|
});
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
function updateBirthday({ month = "", day = 0, year = 0 } = {}) {
|
|
17
|
-
return useNuxtApp().$api<
|
|
24
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/birthday", {
|
|
18
25
|
method: "PUT",
|
|
19
26
|
body: { month, day, year },
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
function updateGender(gender = "") {
|
|
24
|
-
return useNuxtApp().$api<
|
|
31
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/gender", {
|
|
25
32
|
method: "PUT",
|
|
26
33
|
body: { gender },
|
|
27
34
|
});
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
function updateEmail(email = "") {
|
|
31
|
-
return useNuxtApp().$api<
|
|
38
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/email", {
|
|
32
39
|
method: "PUT",
|
|
33
40
|
body: { email },
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
function updateContact(contact = "") {
|
|
38
|
-
return useNuxtApp().$api<
|
|
45
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/contact", {
|
|
39
46
|
method: "PUT",
|
|
40
47
|
body: { contact },
|
|
41
48
|
});
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
function updateUserFieldById(id = "", field = "", value = "") {
|
|
45
|
-
return useNuxtApp().$api<
|
|
52
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/field/${id}`, {
|
|
46
53
|
method: "PATCH",
|
|
47
54
|
body: { field, value },
|
|
48
55
|
});
|
|
@@ -54,14 +61,14 @@ export default function useUser() {
|
|
|
54
61
|
search = "",
|
|
55
62
|
page = 1,
|
|
56
63
|
} = {}) {
|
|
57
|
-
return useNuxtApp().$api<
|
|
64
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users", {
|
|
58
65
|
method: "GET",
|
|
59
66
|
query: { status, search, page, type },
|
|
60
67
|
});
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
function getById(id = "") {
|
|
64
|
-
return useNuxtApp().$api<
|
|
71
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/id/${id}`, {
|
|
65
72
|
method: "GET",
|
|
66
73
|
});
|
|
67
74
|
}
|
|
@@ -74,7 +81,7 @@ export default function useUser() {
|
|
|
74
81
|
referralCode = "",
|
|
75
82
|
type = "",
|
|
76
83
|
} = {}) {
|
|
77
|
-
return useNuxtApp().$api<
|
|
84
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/invite/${id}`, {
|
|
78
85
|
method: "POST",
|
|
79
86
|
body: { firstName, lastName, password, referralCode, type },
|
|
80
87
|
});
|
package/composables/useUtils.ts
CHANGED
|
@@ -199,23 +199,32 @@ export default function useUtils() {
|
|
|
199
199
|
// console.log(formatNumber(1234.56, { useSymbol: true, currency: "EUR", locale: "de-DE" })); // "1.234,56 €"
|
|
200
200
|
// console.log(formatNumber(1234.56, { useSymbol: true, currency: "EUR", locale: "de-DE", decimalPlaces: 0 })); // "1.234 €"
|
|
201
201
|
|
|
202
|
-
function computeTieredCost(
|
|
202
|
+
function computeTieredCost(
|
|
203
|
+
seats: number,
|
|
204
|
+
tiers: { min: number; max: number; price: number }[],
|
|
205
|
+
remainingDays?: number,
|
|
206
|
+
totalDaysInMonth?: number
|
|
207
|
+
) {
|
|
203
208
|
let totalCost = 0;
|
|
204
209
|
|
|
205
|
-
for (let i =
|
|
206
|
-
|
|
210
|
+
for (let i = 1; i <= seats; i++) {
|
|
211
|
+
for (const { min, max, price } of tiers) {
|
|
212
|
+
const effectiveMax = max === 0 ? Infinity : max;
|
|
207
213
|
|
|
208
|
-
|
|
214
|
+
if (i >= min && i <= effectiveMax) {
|
|
215
|
+
// Prorate the cost for this seat based on its tier price
|
|
216
|
+
if (remainingDays && totalDaysInMonth) {
|
|
217
|
+
totalCost += price * (remainingDays / totalDaysInMonth);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
209
220
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
totalCost += price;
|
|
222
|
+
break; // Stop checking once we apply the correct tier pricing
|
|
223
|
+
}
|
|
213
224
|
}
|
|
214
|
-
|
|
215
|
-
if (seats <= max) break; // Stop when all seats are counted
|
|
216
225
|
}
|
|
217
226
|
|
|
218
|
-
return totalCost;
|
|
227
|
+
return totalCost; // This now returns the total prorated cost
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
function convertPermissionsToArray(permissions: TPermissions) {
|
|
@@ -232,6 +241,30 @@ export default function useUtils() {
|
|
|
232
241
|
};
|
|
233
242
|
}
|
|
234
243
|
|
|
244
|
+
function getRouteParam(field = "") {
|
|
245
|
+
if (!field) return "";
|
|
246
|
+
|
|
247
|
+
return (useRoute().params[field] as string) ?? "";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function replaceMatch(str: string, match: string, replace: string) {
|
|
251
|
+
return str.replace(new RegExp(match, "g"), replace);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function setRouteParams(...args: Array<Record<string, string>>) {
|
|
255
|
+
const params: Record<string, string> = {};
|
|
256
|
+
|
|
257
|
+
args.forEach((arg) => {
|
|
258
|
+
Object.entries(arg).forEach(([key, value]) => {
|
|
259
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
260
|
+
params[key] = value;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
return params;
|
|
266
|
+
}
|
|
267
|
+
|
|
235
268
|
return {
|
|
236
269
|
requiredRule,
|
|
237
270
|
emailRule,
|
|
@@ -254,5 +287,8 @@ export default function useUtils() {
|
|
|
254
287
|
requireListRule,
|
|
255
288
|
convertPermissionsToArray,
|
|
256
289
|
extractMonthYear,
|
|
290
|
+
getRouteParam,
|
|
291
|
+
replaceMatch,
|
|
292
|
+
setRouteParams,
|
|
257
293
|
};
|
|
258
294
|
}
|
|
@@ -5,10 +5,11 @@ export default function useUser() {
|
|
|
5
5
|
search = "",
|
|
6
6
|
page = 1,
|
|
7
7
|
email = "",
|
|
8
|
+
app = "",
|
|
8
9
|
} = {}) {
|
|
9
|
-
return useNuxtApp().$api<
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>("/api/verifications", {
|
|
10
11
|
method: "GET",
|
|
11
|
-
query: { status, search, page, type, email },
|
|
12
|
+
query: { status, search, page, type, email, app },
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
|
package/nuxt.config.ts
CHANGED
|
@@ -25,9 +25,7 @@ export default defineNuxtConfig({
|
|
|
25
25
|
APP_AFFILIATE: (process.env.APP_AFFILIATE as string) ?? "",
|
|
26
26
|
APP_INVENTORY: (process.env.APP_INVENTORY as string) ?? "",
|
|
27
27
|
APP_ASSET: (process.env.APP_ASSET as string) ?? "",
|
|
28
|
-
|
|
29
|
-
APP_BOOK_KEEPING: (process.env.APP_BOOK_KEEPING as string) ?? "",
|
|
30
|
-
APP_ZONAL: (process.env.APP_ZONAL as string) ?? "",
|
|
28
|
+
APP_FINANCE: (process.env.APP_FINANCE as string) ?? "",
|
|
31
29
|
},
|
|
32
30
|
},
|
|
33
31
|
|
package/package.json
CHANGED
package/types/org.d.ts
CHANGED
package/types/role.d.ts
CHANGED
package/types/user.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ declare type TUser = {
|
|
|
7
7
|
lastName: string;
|
|
8
8
|
suffix?: string;
|
|
9
9
|
birthMonth?: string;
|
|
10
|
-
|
|
10
|
+
birthDay?: string;
|
|
11
11
|
birthYear?: string;
|
|
12
|
+
gender?: string;
|
|
13
|
+
contact?: string;
|
|
12
14
|
profile?: string;
|
|
13
15
|
defaultOrg?: string;
|
|
14
16
|
createdAt: string;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
export default function useAdminPermission() {
|
|
2
|
-
const permissions: TPermissions = {
|
|
3
|
-
organizations: {
|
|
4
|
-
"see-all-organizations": {
|
|
5
|
-
check: true,
|
|
6
|
-
description: "Allows the user to view the list of all organizations.",
|
|
7
|
-
},
|
|
8
|
-
"see-organization-details": {
|
|
9
|
-
check: true,
|
|
10
|
-
description:
|
|
11
|
-
"Allows the user to view the details of a specific organization.",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
"promo-codes": {
|
|
15
|
-
"create-promo-code": {
|
|
16
|
-
check: true,
|
|
17
|
-
description: "Allows the user to add new promo codes to the system.",
|
|
18
|
-
},
|
|
19
|
-
"see-promo-code-details": {
|
|
20
|
-
check: true,
|
|
21
|
-
description:
|
|
22
|
-
"Allows the user to view the details of a specific promo code.",
|
|
23
|
-
},
|
|
24
|
-
"edit-promo-code-details": {
|
|
25
|
-
check: true,
|
|
26
|
-
description:
|
|
27
|
-
"Allows the user to update the promo code’s name, discount value, and other settings.",
|
|
28
|
-
},
|
|
29
|
-
"change-promo-code-status": {
|
|
30
|
-
check: true,
|
|
31
|
-
description:
|
|
32
|
-
"Allows the user to activate, deactivate, or expire a promo code.",
|
|
33
|
-
},
|
|
34
|
-
"delete-promo-code": {
|
|
35
|
-
check: true,
|
|
36
|
-
description:
|
|
37
|
-
"Allows the user to remove a promo code from the system permanently.",
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
users: {
|
|
41
|
-
"see-all-users": {
|
|
42
|
-
check: true,
|
|
43
|
-
description: "Allows the user to view the list of all users.",
|
|
44
|
-
},
|
|
45
|
-
"see-user-details": {
|
|
46
|
-
check: true,
|
|
47
|
-
description: "Allows the user to view the details of a specific user.",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
invitations: {
|
|
51
|
-
"see-all-invitations": {
|
|
52
|
-
check: true,
|
|
53
|
-
description: "Allows the user to view the list of all invitations.",
|
|
54
|
-
},
|
|
55
|
-
"see-invitation-details": {
|
|
56
|
-
check: true,
|
|
57
|
-
description:
|
|
58
|
-
"Allows the user to view the details of a specific invitation.",
|
|
59
|
-
},
|
|
60
|
-
"edit-invitation-details": {
|
|
61
|
-
check: true,
|
|
62
|
-
description:
|
|
63
|
-
"Allows the user to update the details of a specific invitation.",
|
|
64
|
-
},
|
|
65
|
-
"change-invitation-status": {
|
|
66
|
-
check: true,
|
|
67
|
-
description: "Allows the user to update the status of an invitation.",
|
|
68
|
-
},
|
|
69
|
-
"delete-invitation": {
|
|
70
|
-
check: true,
|
|
71
|
-
description:
|
|
72
|
-
"Allows the user to remove an invitation from the system permanently.",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
members: {
|
|
76
|
-
"see-all-members": {
|
|
77
|
-
check: true,
|
|
78
|
-
description: "Allows the user to view the list of all members.",
|
|
79
|
-
},
|
|
80
|
-
"see-member-details": {
|
|
81
|
-
check: true,
|
|
82
|
-
description:
|
|
83
|
-
"Allows the user to view the details of a specific member.",
|
|
84
|
-
},
|
|
85
|
-
"change-member-status": {
|
|
86
|
-
check: true,
|
|
87
|
-
description: "Allows the user to update the status of a member.",
|
|
88
|
-
},
|
|
89
|
-
"remove-member": {
|
|
90
|
-
check: true,
|
|
91
|
-
description: "Allows the user to remove a member from the system.",
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
"roles-and-permissions": {
|
|
95
|
-
"view-all-roles": {
|
|
96
|
-
check: true,
|
|
97
|
-
description: "Allows the user to view the list of all roles.",
|
|
98
|
-
},
|
|
99
|
-
"view-role-details": {
|
|
100
|
-
check: true,
|
|
101
|
-
description: "Allows the user to view the details of a specific role.",
|
|
102
|
-
},
|
|
103
|
-
"update-role-name": {
|
|
104
|
-
check: true,
|
|
105
|
-
description: "Allows the user to edit the name of an existing role.",
|
|
106
|
-
},
|
|
107
|
-
"update-role-permissions": {
|
|
108
|
-
check: true,
|
|
109
|
-
description:
|
|
110
|
-
"Allows the user to modify permissions assigned to a role.",
|
|
111
|
-
},
|
|
112
|
-
"update-role-status": {
|
|
113
|
-
check: true,
|
|
114
|
-
description: "Allows the user to activate or deactivate a role.",
|
|
115
|
-
},
|
|
116
|
-
"delete-role": {
|
|
117
|
-
check: true,
|
|
118
|
-
description:
|
|
119
|
-
"Allows the user to remove a role from the system permanently.",
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
permissions,
|
|
126
|
-
};
|
|
127
|
-
}
|