@eeplatform/nuxt-layer-common 1.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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.editorconfig +12 -0
- package/.github/workflows/main.yml +17 -0
- package/.github/workflows/publish.yml +39 -0
- package/.nuxtrc +1 -0
- package/.playground/app.vue +37 -0
- package/.playground/nuxt.config.ts +20 -0
- package/CHANGELOG.md +7 -0
- package/README.md +73 -0
- package/app.vue +3 -0
- package/components/AddPaymentMethod.vue +585 -0
- package/components/BtnUploadFile.vue +139 -0
- package/components/ConfirmDialog.vue +66 -0
- package/components/Container/Standard.vue +33 -0
- package/components/Input/Date.vue +177 -0
- package/components/Input/ListGroupSelection.vue +93 -0
- package/components/Input/NewDate.vue +123 -0
- package/components/Input/Number.vue +124 -0
- package/components/Input/Password.vue +35 -0
- package/components/InputLabel.vue +18 -0
- package/components/InvitationMain.vue +195 -0
- package/components/Layout/Header.vue +285 -0
- package/components/Layout/NavigationDrawer.vue +52 -0
- package/components/LinkHome.vue +9 -0
- package/components/ListItem.vue +35 -0
- package/components/LocalPagination.vue +41 -0
- package/components/MemberMain.vue +452 -0
- package/components/NavigationItem.vue +73 -0
- package/components/PlaceholderComponent.vue +34 -0
- package/components/RolePermissionFormCreate.vue +179 -0
- package/components/RolePermissionFormPreviewUpdate.vue +184 -0
- package/components/RolePermissionMain.vue +376 -0
- package/components/Snackbar.vue +23 -0
- package/components/SpecificAttr.vue +57 -0
- package/components/Std/Pagination.vue +52 -0
- package/components/SwitchContext.vue +109 -0
- package/components/SwitchOrg.vue +159 -0
- package/components/TableList.vue +130 -0
- package/composables/useAddress.ts +144 -0
- package/composables/useChartOfAccount.ts +62 -0
- package/composables/useCommonPermission.ts +130 -0
- package/composables/useFile.ts +29 -0
- package/composables/useInvoice.ts +42 -0
- package/composables/useLocal.ts +63 -0
- package/composables/useLocalAuth.ts +157 -0
- package/composables/useLocalSetup.ts +46 -0
- package/composables/useMember.ts +107 -0
- package/composables/useOrder.ts +22 -0
- package/composables/useOrg.ts +106 -0
- package/composables/useOrgPermission.ts +27 -0
- package/composables/usePayment.ts +22 -0
- package/composables/usePaymentMethod.ts +347 -0
- package/composables/usePermission.ts +54 -0
- package/composables/usePrice.ts +15 -0
- package/composables/usePromoCode.ts +43 -0
- package/composables/useRecapPermission.ts +26 -0
- package/composables/useRole.ts +89 -0
- package/composables/useSchoolPermission.ts +13 -0
- package/composables/useSubscription.ts +264 -0
- package/composables/useUser.ts +102 -0
- package/composables/useUtils.ts +294 -0
- package/composables/useVerification.ts +19 -0
- package/error.vue +41 -0
- package/eslint.config.js +3 -0
- package/layouts/plain.vue +7 -0
- package/middleware/01.auth.ts +14 -0
- package/middleware/org.ts +16 -0
- package/nuxt.config.ts +48 -0
- package/package.json +35 -0
- package/pages/index.vue +3 -0
- package/pages/payment-method-cancel-link.vue +31 -0
- package/pages/payment-method-failed-link.vue +31 -0
- package/pages/payment-method-linked.vue +31 -0
- package/pages/require-organization-membership.vue +47 -0
- package/pages/unauthorized.vue +29 -0
- package/plugins/API.ts +58 -0
- package/plugins/iconify.client.ts +5 -0
- package/plugins/vuetify.ts +55 -0
- package/public/bdo-logo.svg +4 -0
- package/public/bpi-logo.svg +74 -0
- package/public/chinabank-logo.svg +120 -0
- package/public/gcash-logo.png +0 -0
- package/public/gcash-logo.svg +65 -0
- package/public/grabpay-logo.svg +99 -0
- package/public/paymaya-logo.jpg +0 -0
- package/public/paymaya-logo.png +0 -0
- package/public/paymaya-logo.svg +25 -0
- package/public/qrph-c567ff0f-ab6d-4662-86bf-24c6c731d8a8-logo.svg +20 -0
- package/public/rcbc-logo.svg +15 -0
- package/public/shopeepay-logo.svg +89 -0
- package/public/ubp-logo.svg +88 -0
- package/tsconfig.json +3 -0
- package/types/address.d.ts +13 -0
- package/types/invoice.d.ts +28 -0
- package/types/local.d.ts +25 -0
- package/types/member.d.ts +12 -0
- package/types/org.d.ts +13 -0
- package/types/payment-method.d.ts +11 -0
- package/types/payment.d.ts +18 -0
- package/types/permission.d.ts +14 -0
- package/types/price.d.ts +17 -0
- package/types/promo-code.d.ts +19 -0
- package/types/role.d.ts +13 -0
- package/types/subscription.d.ts +29 -0
- package/types/user.d.ts +21 -0
- package/types/verification.d.ts +15 -0
- package/types/xendit.d.ts +3 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export default function useLocal() {
|
|
2
|
+
const appConfig = useRuntimeConfig().public;
|
|
3
|
+
|
|
4
|
+
const { cookieConfig } = appConfig;
|
|
5
|
+
|
|
6
|
+
function getUserFromCookie() {
|
|
7
|
+
return useCookie("user", cookieConfig).value;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const drawer = useState("drawer", () => true);
|
|
11
|
+
|
|
12
|
+
const { APP_INVENTORY, APP_ASSET, APP_FINANCE } = appConfig;
|
|
13
|
+
const { currentOrg } = useOrg();
|
|
14
|
+
|
|
15
|
+
const apps = computed(() => {
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
title: "Finance",
|
|
19
|
+
icon: "mdi-file-document-multiple",
|
|
20
|
+
link: APP_FINANCE as string,
|
|
21
|
+
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: "Inventory",
|
|
25
|
+
icon: "mdi-warehouse",
|
|
26
|
+
link: APP_INVENTORY as string,
|
|
27
|
+
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: "Asset",
|
|
31
|
+
icon: "mdi-package-variant-closed",
|
|
32
|
+
link: APP_ASSET as string,
|
|
33
|
+
landingPage: `org/${currentOrg.value ?? ""}`,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function redirect(link: string, page?: string) {
|
|
39
|
+
const href = page ? `${link}/${page}` : link;
|
|
40
|
+
|
|
41
|
+
window.location.href = href;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const headerSearch = useState("headerSearch", () => "");
|
|
45
|
+
|
|
46
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
47
|
+
const page = ref(1);
|
|
48
|
+
const pages = ref(0);
|
|
49
|
+
const pageRange = ref("");
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
cookieConfig,
|
|
53
|
+
getUserFromCookie,
|
|
54
|
+
drawer,
|
|
55
|
+
apps,
|
|
56
|
+
redirect,
|
|
57
|
+
headerSearch,
|
|
58
|
+
items,
|
|
59
|
+
page,
|
|
60
|
+
pages,
|
|
61
|
+
pageRange,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export default function useLocalAuth() {
|
|
2
|
+
const { cookieConfig } = useRuntimeConfig().public;
|
|
3
|
+
|
|
4
|
+
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
5
|
+
|
|
6
|
+
function authenticate() {
|
|
7
|
+
if (currentUser.value) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Get access token from cookies
|
|
12
|
+
const accessToken = useCookie("accessToken", cookieConfig).value;
|
|
13
|
+
|
|
14
|
+
if (!accessToken) {
|
|
15
|
+
// Redirect to login page if no access token
|
|
16
|
+
navigateTo({ name: "index" });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const user = useCookie("user", cookieConfig).value;
|
|
20
|
+
|
|
21
|
+
const { data: getCurrentUserReq, error: getCurrentUserErr } =
|
|
22
|
+
useLazyAsyncData("get-current-user", () =>
|
|
23
|
+
useNuxtApp().$api<TUser>(`/api/users/id/${user}`)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
watchEffect(() => {
|
|
27
|
+
if (getCurrentUserReq.value) {
|
|
28
|
+
currentUser.value = getCurrentUserReq.value;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
watchEffect(() => {
|
|
33
|
+
if (getCurrentUserErr.value) {
|
|
34
|
+
// Redirect to login page if user authentication fails
|
|
35
|
+
navigateTo({ name: "index" });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function login({ email = "", password = "", role = "" }) {
|
|
41
|
+
return useNuxtApp().$api<TKeyValuePair>("/api/auth/login", {
|
|
42
|
+
method: "POST",
|
|
43
|
+
body: JSON.stringify({ email, password, role }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function setToken({
|
|
48
|
+
refreshToken = "",
|
|
49
|
+
accessToken = "",
|
|
50
|
+
user = "",
|
|
51
|
+
org = "",
|
|
52
|
+
}) {
|
|
53
|
+
useCookie("accessToken", cookieConfig).value = accessToken;
|
|
54
|
+
useCookie("refreshToken", cookieConfig).value = refreshToken;
|
|
55
|
+
useCookie("user", cookieConfig).value = user;
|
|
56
|
+
useCookie("org", cookieConfig).value = org;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clearCookies() {
|
|
60
|
+
useCookie("accessToken", cookieConfig).value = null;
|
|
61
|
+
useCookie("refreshToken", cookieConfig).value = null;
|
|
62
|
+
useCookie("user", cookieConfig).value = null;
|
|
63
|
+
useCookie("organization", cookieConfig).value = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function logout() {
|
|
67
|
+
const refreshToken = useCookie("refreshToken", cookieConfig).value;
|
|
68
|
+
if (refreshToken) {
|
|
69
|
+
try {
|
|
70
|
+
await useNuxtApp().$api(`/api/auth/logout/${refreshToken}`, {
|
|
71
|
+
method: "DELETE",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
clearCookies();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("Logout failed:", error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function getCurrentUser() {
|
|
82
|
+
const user = useCookie("user", cookieConfig).value;
|
|
83
|
+
if (!user) return null;
|
|
84
|
+
try {
|
|
85
|
+
const _user = await useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
|
|
86
|
+
method: "GET",
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
currentUser.value = _user;
|
|
90
|
+
return _user;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.log("Error fetching current user:", error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function forgotPassword(email: string) {
|
|
97
|
+
if (!email) {
|
|
98
|
+
throw new Error("Email is required for password reset request.");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const response = await useNuxtApp().$api("/api/auth/forget-password", {
|
|
103
|
+
method: "POST",
|
|
104
|
+
body: JSON.stringify({ email }),
|
|
105
|
+
headers: { "Content-Type": "application/json" },
|
|
106
|
+
});
|
|
107
|
+
return response;
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error("Error in password reset request:", error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function resetPassword(
|
|
115
|
+
otp: string,
|
|
116
|
+
newPassword: string,
|
|
117
|
+
passwordConfirmation: string
|
|
118
|
+
) {
|
|
119
|
+
try {
|
|
120
|
+
return await useNuxtApp().$api("/api/auth/reset-password", {
|
|
121
|
+
method: "POST",
|
|
122
|
+
body: JSON.stringify({ otp, newPassword, passwordConfirmation }),
|
|
123
|
+
headers: { "Content-Type": "application/json" },
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error("Error resetting password:", error);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function verify(id: string) {
|
|
132
|
+
return useNuxtApp().$api<TKeyValuePair>(`/api/auth/verify/${id}`, {
|
|
133
|
+
method: "GET",
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function signUp(email: string, referral: string) {
|
|
138
|
+
return useNuxtApp().$api<TKeyValuePair>("/api/auth/sign-up", {
|
|
139
|
+
method: "POST",
|
|
140
|
+
body: { email, referral },
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
authenticate,
|
|
146
|
+
login,
|
|
147
|
+
logout,
|
|
148
|
+
clearCookies,
|
|
149
|
+
getCurrentUser,
|
|
150
|
+
setToken,
|
|
151
|
+
forgotPassword,
|
|
152
|
+
resetPassword,
|
|
153
|
+
currentUser,
|
|
154
|
+
verify,
|
|
155
|
+
signUp,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export default function useMember() {
|
|
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 --");
|
|
6
|
+
|
|
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
|
+
}));
|
|
23
|
+
|
|
24
|
+
function getByUserId(user: string) {
|
|
25
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getByUserType(user: string, type: string, org?: string) {
|
|
29
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}/app/${type}`, {
|
|
30
|
+
method: "GET",
|
|
31
|
+
query: { org },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function getAll({
|
|
36
|
+
page = 1,
|
|
37
|
+
search = "",
|
|
38
|
+
limit = 10,
|
|
39
|
+
user = "",
|
|
40
|
+
org = "",
|
|
41
|
+
type = "",
|
|
42
|
+
status = "active",
|
|
43
|
+
} = {}) {
|
|
44
|
+
return useNuxtApp().$api<Record<string, any>>("/api/members", {
|
|
45
|
+
method: "GET",
|
|
46
|
+
query: { page, limit, search, user, org, type, status },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function createUserByVerification(
|
|
50
|
+
verificationId: string,
|
|
51
|
+
payload: Record<string, any>
|
|
52
|
+
) {
|
|
53
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
54
|
+
`/api/users/invite/${verificationId}`,
|
|
55
|
+
{
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: payload,
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function createMemberInvite(verificatonId: string) {
|
|
63
|
+
return useNuxtApp().$api<TMember>(
|
|
64
|
+
`/api/members/verification/${verificatonId}`,
|
|
65
|
+
{
|
|
66
|
+
method: "POST",
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function updateMemberStatus(id: string, status: string) {
|
|
71
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
72
|
+
`/api/members/status/${status}/id/${id}`,
|
|
73
|
+
{
|
|
74
|
+
method: "PUT",
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function updateMemberRole(
|
|
80
|
+
id: string,
|
|
81
|
+
role: string,
|
|
82
|
+
type: string,
|
|
83
|
+
org: string
|
|
84
|
+
) {
|
|
85
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
86
|
+
`/api/members/id/${id}/role/${role}/type/${type}/org/${org}`,
|
|
87
|
+
{
|
|
88
|
+
method: "PUT",
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
members,
|
|
94
|
+
member,
|
|
95
|
+
page,
|
|
96
|
+
pages,
|
|
97
|
+
pageRange,
|
|
98
|
+
|
|
99
|
+
getAll,
|
|
100
|
+
getByUserId,
|
|
101
|
+
createUserByVerification,
|
|
102
|
+
createMemberInvite,
|
|
103
|
+
getByUserType,
|
|
104
|
+
updateMemberStatus,
|
|
105
|
+
updateMemberRole,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default function useOrder() {
|
|
2
|
+
function getOrders({
|
|
3
|
+
search = "",
|
|
4
|
+
id = "",
|
|
5
|
+
page = 1,
|
|
6
|
+
status = "succeeded",
|
|
7
|
+
} = {}) {
|
|
8
|
+
return useNuxtApp().$api<Record<string, any>>("/api/orders", {
|
|
9
|
+
method: "GET",
|
|
10
|
+
query: {
|
|
11
|
+
search,
|
|
12
|
+
id,
|
|
13
|
+
page,
|
|
14
|
+
status,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
getOrders,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export default function useOrg() {
|
|
2
|
+
function getAll({ page = 1, search = "", limit = 20, status = "" } = {}) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
|
|
4
|
+
method: "GET",
|
|
5
|
+
query: {
|
|
6
|
+
page,
|
|
7
|
+
search,
|
|
8
|
+
limit,
|
|
9
|
+
status,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
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: "",
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
function reset() {
|
|
48
|
+
org.value._id = "";
|
|
49
|
+
org.value.name = "";
|
|
50
|
+
org.value.email = "";
|
|
51
|
+
org.value.contact = "";
|
|
52
|
+
org.value.busInst = "";
|
|
53
|
+
org.value.type = "";
|
|
54
|
+
org.value.status = "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function set({
|
|
58
|
+
_id = "",
|
|
59
|
+
name = "",
|
|
60
|
+
email = "",
|
|
61
|
+
contact = "",
|
|
62
|
+
busInst = "",
|
|
63
|
+
type = "",
|
|
64
|
+
status = "",
|
|
65
|
+
} = {}) {
|
|
66
|
+
org.value._id = _id;
|
|
67
|
+
org.value.name = name;
|
|
68
|
+
org.value.email = email;
|
|
69
|
+
org.value.contact = contact;
|
|
70
|
+
org.value.busInst = busInst;
|
|
71
|
+
org.value.type = type;
|
|
72
|
+
org.value.status = status;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const perSeatPrice = 300;
|
|
76
|
+
const seats = useState("seats", () => 1);
|
|
77
|
+
const total = computed(() => seats.value * perSeatPrice);
|
|
78
|
+
|
|
79
|
+
function getByName(name = "") {
|
|
80
|
+
return useNuxtApp().$api<TOrg>(`/api/organizations/name/${name}`, {
|
|
81
|
+
method: "GET",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { currentUser } = useLocalAuth();
|
|
86
|
+
|
|
87
|
+
const currentOrg = computed(
|
|
88
|
+
() =>
|
|
89
|
+
(useRoute().params.organization as string) ||
|
|
90
|
+
currentUser.value?.defaultOrg
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
org,
|
|
95
|
+
getAll,
|
|
96
|
+
getByUserId,
|
|
97
|
+
reset,
|
|
98
|
+
set,
|
|
99
|
+
perSeatPrice,
|
|
100
|
+
seats,
|
|
101
|
+
total,
|
|
102
|
+
getByName,
|
|
103
|
+
currentOrg,
|
|
104
|
+
getById,
|
|
105
|
+
};
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default function usePayment() {
|
|
2
|
+
function getPayments({
|
|
3
|
+
search = "",
|
|
4
|
+
id = "",
|
|
5
|
+
page = 1,
|
|
6
|
+
status = "completed",
|
|
7
|
+
} = {}) {
|
|
8
|
+
return useNuxtApp().$api<Record<string, any>>("/api/payments", {
|
|
9
|
+
method: "GET",
|
|
10
|
+
query: {
|
|
11
|
+
search,
|
|
12
|
+
id,
|
|
13
|
+
page,
|
|
14
|
+
status,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
getPayments,
|
|
21
|
+
};
|
|
22
|
+
}
|