@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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export function useCommonPermissions() {
|
|
2
|
+
const invitationPermissions: Record<string, TPermission> = {
|
|
3
|
+
"create-invitation": {
|
|
4
|
+
check: true,
|
|
5
|
+
description:
|
|
6
|
+
"Allows the user to create a new invitation for a invitation to join the organization.",
|
|
7
|
+
},
|
|
8
|
+
"view-invitations": {
|
|
9
|
+
check: true,
|
|
10
|
+
description:
|
|
11
|
+
"Allows the user to view the list of all invitation in the organization.",
|
|
12
|
+
},
|
|
13
|
+
"cancel-invitation": {
|
|
14
|
+
check: true,
|
|
15
|
+
description:
|
|
16
|
+
"Allows the user to permanently remove a invitation from the organization.",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const memberPermissions: Record<string, TPermission> = {
|
|
21
|
+
"view-members": {
|
|
22
|
+
check: true,
|
|
23
|
+
description:
|
|
24
|
+
"Allows the user to view the list of all members in the organization.",
|
|
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
|
+
},
|
|
31
|
+
"suspend-member": {
|
|
32
|
+
check: true,
|
|
33
|
+
description: "Allows the user to suspend a member's account temporarily.",
|
|
34
|
+
},
|
|
35
|
+
"activate-member": {
|
|
36
|
+
check: true,
|
|
37
|
+
description:
|
|
38
|
+
"Allows the user to reactivate a suspended member's account.",
|
|
39
|
+
},
|
|
40
|
+
"delete-member": {
|
|
41
|
+
check: true,
|
|
42
|
+
description:
|
|
43
|
+
"Allows the user to permanently remove a member from the organization.",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const rolePermissions: Record<string, TPermission> = {
|
|
48
|
+
"add-role": {
|
|
49
|
+
check: true,
|
|
50
|
+
description: "Allows the user to add a new role to the system.",
|
|
51
|
+
},
|
|
52
|
+
"see-all-roles": {
|
|
53
|
+
check: true,
|
|
54
|
+
description: "Allows the user to view the list of all roles.",
|
|
55
|
+
},
|
|
56
|
+
"see-role-details": {
|
|
57
|
+
check: true,
|
|
58
|
+
description: "Allows the user to view the details of a specific role.",
|
|
59
|
+
},
|
|
60
|
+
"delete-role": {
|
|
61
|
+
check: true,
|
|
62
|
+
description:
|
|
63
|
+
"Allows the user to remove a role from the system permanently.",
|
|
64
|
+
},
|
|
65
|
+
"update-role": {
|
|
66
|
+
check: true,
|
|
67
|
+
description: "Allows the user to update the details of an existing role.",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
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
|
+
|
|
123
|
+
return {
|
|
124
|
+
invitationPermissions,
|
|
125
|
+
memberPermissions,
|
|
126
|
+
rolePermissions,
|
|
127
|
+
feedbackPermissions,
|
|
128
|
+
workOrderPermissions,
|
|
129
|
+
};
|
|
130
|
+
}
|
package/composables/useLocal.ts
CHANGED
|
@@ -9,27 +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
|
-
} = appConfig;
|
|
12
|
+
const { APP_INVENTORY, APP_ASSET, APP_FINANCE } = appConfig;
|
|
19
13
|
const { currentOrg } = useOrg();
|
|
20
14
|
|
|
21
15
|
const apps = computed(() => {
|
|
22
16
|
return [
|
|
23
17
|
{
|
|
24
|
-
title: "
|
|
18
|
+
title: "Finance",
|
|
25
19
|
icon: "mdi-file-document-multiple",
|
|
26
|
-
link:
|
|
27
|
-
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
title: "Bookkeeping",
|
|
31
|
-
icon: "mdi-file-document-edit-outline",
|
|
32
|
-
link: APP_BOOK_KEEPING as string,
|
|
20
|
+
link: APP_FINANCE as string,
|
|
33
21
|
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
34
22
|
},
|
|
35
23
|
{
|
|
@@ -44,12 +32,6 @@ export default function useLocal() {
|
|
|
44
32
|
link: APP_ASSET as string,
|
|
45
33
|
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
46
34
|
},
|
|
47
|
-
{
|
|
48
|
-
title: "Zonal",
|
|
49
|
-
icon: "mdi-hospital-marker",
|
|
50
|
-
link: APP_ZONAL as string,
|
|
51
|
-
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
52
|
-
},
|
|
53
35
|
];
|
|
54
36
|
});
|
|
55
37
|
|
|
@@ -61,6 +43,11 @@ export default function useLocal() {
|
|
|
61
43
|
|
|
62
44
|
const headerSearch = useState("headerSearch", () => "");
|
|
63
45
|
|
|
46
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
47
|
+
const page = ref(1);
|
|
48
|
+
const pages = ref(0);
|
|
49
|
+
const pageRange = ref("");
|
|
50
|
+
|
|
64
51
|
return {
|
|
65
52
|
cookieConfig,
|
|
66
53
|
getUserFromCookie,
|
|
@@ -68,5 +55,9 @@ export default function useLocal() {
|
|
|
68
55
|
apps,
|
|
69
56
|
redirect,
|
|
70
57
|
headerSearch,
|
|
58
|
+
items,
|
|
59
|
+
page,
|
|
60
|
+
pages,
|
|
61
|
+
pageRange,
|
|
71
62
|
};
|
|
72
63
|
}
|
|
@@ -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
|
|
|
@@ -74,26 +78,6 @@ export default function useLocalAuth() {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
function getById(id: string) {
|
|
78
|
-
return useNuxtApp().$api<TUser>(`/api/users/id/${id}`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const user = useCookie("user", cookieConfig).value ?? "";
|
|
82
|
-
|
|
83
|
-
if (currentUser.value === null) {
|
|
84
|
-
const { data: userData } = useLazyAsyncData("getCurrentUser", async () =>
|
|
85
|
-
useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
|
|
86
|
-
method: "GET",
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
watchEffect(() => {
|
|
91
|
-
if (userData.value) {
|
|
92
|
-
currentUser.value = userData.value;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
81
|
async function getCurrentUser() {
|
|
98
82
|
const user = useCookie("user", cookieConfig).value;
|
|
99
83
|
if (!user) return null;
|
|
@@ -157,8 +141,6 @@ export default function useLocalAuth() {
|
|
|
157
141
|
});
|
|
158
142
|
}
|
|
159
143
|
|
|
160
|
-
const permissions = useState("permissions", (): Array<string> => []);
|
|
161
|
-
|
|
162
144
|
return {
|
|
163
145
|
authenticate,
|
|
164
146
|
login,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function useLocalSetup(type: string) {
|
|
2
|
+
const { currentUser } = useLocalAuth();
|
|
3
|
+
|
|
4
|
+
const userId = computed(() => currentUser.value?._id ?? "");
|
|
5
|
+
|
|
6
|
+
const { getByUserIdType } = useMember();
|
|
7
|
+
|
|
8
|
+
const { data: userMemberData } = useLazyAsyncData(
|
|
9
|
+
"get-member-by-id",
|
|
10
|
+
() => getByUserIdType(userId.value, type),
|
|
11
|
+
{ watch: [userId], immediate: false }
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const { getRoleById } = useRole();
|
|
15
|
+
|
|
16
|
+
const roleId = computed(() => userMemberData.value?.role ?? "");
|
|
17
|
+
|
|
18
|
+
const userAppRole = useState<Record<string, any> | null>(
|
|
19
|
+
"userAppRole",
|
|
20
|
+
() => null
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const { data: getRoleByIdReq } = useLazyAsyncData(
|
|
24
|
+
"get-role-by-id",
|
|
25
|
+
() => getRoleById(roleId.value),
|
|
26
|
+
{ watch: [roleId], immediate: false }
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
watchEffect(() => {
|
|
30
|
+
if (getRoleByIdReq.value) {
|
|
31
|
+
userAppRole.value = getRoleByIdReq.value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
userAppRole,
|
|
37
|
+
};
|
|
38
|
+
}
|
package/composables/useMember.ts
CHANGED
|
@@ -1,86 +1,104 @@
|
|
|
1
1
|
export default function useMember() {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
user: "",
|
|
7
|
-
role: "",
|
|
8
|
-
status: "",
|
|
9
|
-
createdAt: "",
|
|
10
|
-
updatedAt: "",
|
|
11
|
-
deletedAt: "",
|
|
12
|
-
};
|
|
13
|
-
});
|
|
2
|
+
const members = useState<Array<TMember>>("members", () => []);
|
|
3
|
+
const page = useState("page", () => 1);
|
|
4
|
+
const pages = useState("pages", () => 0);
|
|
5
|
+
const pageRange = useState("pageRange", () => "-- - -- of --");
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const member = useState<TMember>("member", () => ({
|
|
8
|
+
_id: "",
|
|
9
|
+
org: "",
|
|
10
|
+
orgName: "",
|
|
11
|
+
roleName: "",
|
|
12
|
+
name: "",
|
|
13
|
+
user: "",
|
|
14
|
+
role: "",
|
|
15
|
+
type: "",
|
|
16
|
+
customerOrgId: "",
|
|
17
|
+
customerSiteId: "",
|
|
18
|
+
status: "",
|
|
19
|
+
createdAt: "",
|
|
20
|
+
updatedAt: "",
|
|
21
|
+
deletedAt: "",
|
|
22
|
+
}));
|
|
24
23
|
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
delete value._id;
|
|
29
|
-
delete value.status;
|
|
24
|
+
function getByUserId(user: string) {
|
|
25
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}`);
|
|
26
|
+
}
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
body: JSON.stringify(value),
|
|
34
|
-
});
|
|
28
|
+
function getByUserIdType(user: string, type: string) {
|
|
29
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}/app/${type}`);
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
function getAll({
|
|
38
|
-
search = "",
|
|
32
|
+
async function getAll({
|
|
39
33
|
page = 1,
|
|
40
|
-
|
|
41
|
-
user = "",
|
|
42
|
-
type = "main",
|
|
34
|
+
search = "",
|
|
43
35
|
limit = 10,
|
|
36
|
+
user = "",
|
|
37
|
+
org = "",
|
|
38
|
+
type = "",
|
|
44
39
|
status = "active",
|
|
45
40
|
} = {}) {
|
|
46
|
-
return useNuxtApp().$api<
|
|
41
|
+
return useNuxtApp().$api<Record<string, any>>("/api/members", {
|
|
47
42
|
method: "GET",
|
|
48
|
-
query: {
|
|
43
|
+
query: { page, limit, search, user, org, type, status },
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
function createUserByVerification(
|
|
47
|
+
verificationId: string,
|
|
48
|
+
payload: Record<string, any>
|
|
49
|
+
) {
|
|
50
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
51
|
+
`/api/users/invite/${verificationId}`,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: payload,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
function
|
|
63
|
-
return useNuxtApp().$api<TMember>(
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
function createMemberInvite(verificatonId: string) {
|
|
60
|
+
return useNuxtApp().$api<TMember>(
|
|
61
|
+
`/api/members/verification/${verificatonId}`,
|
|
62
|
+
{
|
|
63
|
+
method: "POST",
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
function updateMemberStatus(id: string, status: string) {
|
|
68
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
69
|
+
`/api/members/status/${status}/id/${id}`,
|
|
70
|
+
{
|
|
71
|
+
method: "PUT",
|
|
72
|
+
}
|
|
73
|
+
);
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
function updateMemberRole(
|
|
77
|
+
id: string,
|
|
78
|
+
role: string,
|
|
79
|
+
type: string,
|
|
80
|
+
org: string
|
|
81
|
+
) {
|
|
82
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
83
|
+
`/api/members/id/${id}/role/${role}/type/${type}/org/${org}`,
|
|
84
|
+
{
|
|
85
|
+
method: "PUT",
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
74
89
|
return {
|
|
90
|
+
members,
|
|
75
91
|
member,
|
|
76
|
-
setMember,
|
|
77
|
-
inviteMember,
|
|
78
|
-
getAll,
|
|
79
92
|
page,
|
|
80
93
|
pages,
|
|
81
94
|
pageRange,
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
|
|
96
|
+
getAll,
|
|
84
97
|
getByUserId,
|
|
98
|
+
createUserByVerification,
|
|
99
|
+
createMemberInvite,
|
|
100
|
+
getByUserIdType,
|
|
101
|
+
updateMemberStatus,
|
|
102
|
+
updateMemberRole,
|
|
85
103
|
};
|
|
86
104
|
}
|
package/composables/useOrg.ts
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
export default function useOrg() {
|
|
2
|
-
function
|
|
2
|
+
function getAll({ page = 1, search = "", limit = 20, status = "" } = {}) {
|
|
3
3
|
return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
|
|
4
4
|
method: "GET",
|
|
5
5
|
query: {
|
|
6
6
|
page,
|
|
7
7
|
search,
|
|
8
|
-
user,
|
|
9
8
|
limit,
|
|
9
|
+
status,
|
|
10
10
|
},
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
function getById(id = "") {
|
|
15
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
16
|
+
`/api/organizations/id/${id}`,
|
|
17
|
+
{
|
|
18
|
+
method: "GET",
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getByUserId({ page = 1, search = "", user = "", limit = 20 } = {}) {
|
|
24
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
25
|
+
`/api/organizations/user/${user}`,
|
|
26
|
+
{
|
|
27
|
+
method: "GET",
|
|
28
|
+
query: {
|
|
29
|
+
page,
|
|
30
|
+
search,
|
|
31
|
+
limit,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const org = ref({
|
|
38
|
+
_id: "",
|
|
39
|
+
name: "",
|
|
40
|
+
email: "",
|
|
41
|
+
contact: "",
|
|
42
|
+
busInst: "",
|
|
43
|
+
type: "",
|
|
44
|
+
status: "",
|
|
24
45
|
});
|
|
25
46
|
|
|
26
47
|
function reset() {
|
|
@@ -71,7 +92,8 @@ export default function useOrg() {
|
|
|
71
92
|
|
|
72
93
|
return {
|
|
73
94
|
org,
|
|
74
|
-
|
|
95
|
+
getAll,
|
|
96
|
+
getByUserId,
|
|
75
97
|
reset,
|
|
76
98
|
set,
|
|
77
99
|
perSeatPrice,
|
|
@@ -79,5 +101,6 @@ export default function useOrg() {
|
|
|
79
101
|
total,
|
|
80
102
|
getByName,
|
|
81
103
|
currentOrg,
|
|
104
|
+
getById,
|
|
82
105
|
};
|
|
83
106
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function useOrgPermission() {
|
|
2
|
+
const { memberPermissions, rolePermissions, invitationPermission } =
|
|
3
|
+
useCommonPermissions();
|
|
4
|
+
const permissions: TPermissions = {
|
|
5
|
+
organizations: {
|
|
6
|
+
"create-organization": {
|
|
7
|
+
check: true,
|
|
8
|
+
description: "Create Organization",
|
|
9
|
+
},
|
|
10
|
+
"view-organization": {
|
|
11
|
+
check: true,
|
|
12
|
+
description: "View Organization",
|
|
13
|
+
},
|
|
14
|
+
"view-organization-details": {
|
|
15
|
+
check: true,
|
|
16
|
+
description: "View Organization Details",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
members: memberPermissions,
|
|
20
|
+
invitations: invitationPermission,
|
|
21
|
+
roles: rolePermissions,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
permissions,
|
|
26
|
+
};
|
|
27
|
+
}
|
package/composables/useRole.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export default function useRole() {
|
|
2
2
|
function createRole(
|
|
3
|
-
{ name, permissions, type } = {} as {
|
|
3
|
+
{ name, permissions, type, org } = {} as {
|
|
4
4
|
name: string;
|
|
5
5
|
permissions: Array<string>;
|
|
6
6
|
type: string;
|
|
7
|
+
org: string;
|
|
7
8
|
}
|
|
8
9
|
) {
|
|
9
10
|
return useNuxtApp().$api("/api/roles", {
|
|
10
11
|
method: "POST",
|
|
11
|
-
body: { name, permissions, type },
|
|
12
|
+
body: { name, permissions, type, org },
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -57,7 +58,7 @@ export default function useRole() {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
function deleteRole(_id: string) {
|
|
60
|
-
return useNuxtApp().$api(`/api/roles/${_id}`, {
|
|
61
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/roles/${_id}`, {
|
|
61
62
|
method: "DELETE",
|
|
62
63
|
});
|
|
63
64
|
}
|
|
@@ -66,6 +67,7 @@ export default function useRole() {
|
|
|
66
67
|
return {
|
|
67
68
|
_id: "",
|
|
68
69
|
name: "",
|
|
70
|
+
org: "",
|
|
69
71
|
permissions: [],
|
|
70
72
|
createdAt: "",
|
|
71
73
|
updatedAt: "",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function useSchoolPermission() {
|
|
2
|
+
const { memberPermissions, rolePermissions, invitationPermission } =
|
|
3
|
+
useCommonPermissions();
|
|
4
|
+
const permissions: TPermissions = {
|
|
5
|
+
members: memberPermissions,
|
|
6
|
+
invitations: invitationPermission,
|
|
7
|
+
roles: rolePermissions,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
permissions,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -69,7 +69,9 @@ export default function useSubscription() {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function getByOrgId(id: string) {
|
|
72
|
-
return useNuxtApp().$api<
|
|
72
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
73
|
+
`/api/subscriptions/org/${id}`
|
|
74
|
+
);
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
function getSubscriptions() {
|
|
@@ -186,6 +188,7 @@ export default function useSubscription() {
|
|
|
186
188
|
}
|
|
187
189
|
|
|
188
190
|
function updateSeatsById({
|
|
191
|
+
transactionId = "",
|
|
189
192
|
subscriptionId = "",
|
|
190
193
|
seats = 0,
|
|
191
194
|
amount = 0,
|
|
@@ -197,6 +200,7 @@ export default function useSubscription() {
|
|
|
197
200
|
body: {
|
|
198
201
|
seats,
|
|
199
202
|
amount,
|
|
203
|
+
transactionId,
|
|
200
204
|
},
|
|
201
205
|
}
|
|
202
206
|
);
|
|
@@ -213,7 +217,7 @@ export default function useSubscription() {
|
|
|
213
217
|
|
|
214
218
|
function addOrgSubscription(value: {
|
|
215
219
|
user: string;
|
|
216
|
-
transactionId
|
|
220
|
+
transactionId?: string;
|
|
217
221
|
promoCode?: string;
|
|
218
222
|
seats: number;
|
|
219
223
|
perSeatPrice: number;
|