@goweekdays/layer-common 1.2.4 → 1.2.5
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 +6 -0
- package/components/ListGroupSelection.vue +116 -0
- package/components/RoleForm.vue +326 -0
- package/components/RolePermissionFormCreate.vue +2 -2
- package/components/RolePermissionMain.vue +119 -184
- package/composables/useAddress.ts +4 -4
- package/composables/useChartOfAccount.ts +7 -10
- package/composables/useFile.ts +4 -7
- package/composables/useInvoice.ts +11 -17
- package/composables/useLocalAuth.ts +7 -7
- package/composables/useMember.ts +12 -18
- package/composables/useOrder.ts +1 -1
- package/composables/useOrg.ts +13 -19
- package/composables/usePayment.ts +1 -1
- package/composables/usePaymentMethod.ts +24 -37
- package/composables/usePermission.ts +2 -1
- package/composables/usePrice.ts +1 -1
- package/composables/usePromoCode.ts +4 -4
- package/composables/useRole.ts +25 -41
- package/composables/useSubscription.ts +25 -37
- package/composables/useUser.ts +10 -10
- package/composables/useUtils.ts +1 -1
- package/composables/useVerification.ts +1 -1
- package/package.json +1 -1
- package/plugins/API.ts +1 -1
- package/plugins/member.client.ts +4 -4
- package/plugins/secure.client.ts +3 -3
- package/types/local.d.ts +6 -0
- package/types/permission.d.ts +2 -0
- package/types/role.d.ts +1 -0
package/composables/useOrg.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function useOrg() {
|
|
2
2
|
function getAll({ page = 1, search = "", limit = 20, status = "" } = {}) {
|
|
3
|
-
return
|
|
3
|
+
return $fetch<Record<string, any>>("/api/organizations", {
|
|
4
4
|
method: "GET",
|
|
5
5
|
query: {
|
|
6
6
|
page,
|
|
@@ -12,26 +12,20 @@ export default function useOrg() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function getById(id = "") {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
method: "GET",
|
|
19
|
-
}
|
|
20
|
-
);
|
|
15
|
+
return $fetch<Record<string, any>>(`/api/organizations/id/${id}`, {
|
|
16
|
+
method: "GET",
|
|
17
|
+
});
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
function getByUserId({ page = 1, search = "", user = "", limit = 20 } = {}) {
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
);
|
|
21
|
+
return $fetch<Record<string, any>>(`/api/organizations/user/${user}`, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
query: {
|
|
24
|
+
page,
|
|
25
|
+
search,
|
|
26
|
+
limit,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
35
29
|
}
|
|
36
30
|
|
|
37
31
|
const org = ref({
|
|
@@ -77,7 +71,7 @@ export default function useOrg() {
|
|
|
77
71
|
const total = computed(() => seats.value * perSeatPrice);
|
|
78
72
|
|
|
79
73
|
function getByName(name = "") {
|
|
80
|
-
return
|
|
74
|
+
return $fetch<TOrg>(`/api/organizations/name/${name}`, {
|
|
81
75
|
method: "GET",
|
|
82
76
|
});
|
|
83
77
|
}
|
|
@@ -9,20 +9,17 @@ export default function usePaymentMethod() {
|
|
|
9
9
|
cancel_return_url = "",
|
|
10
10
|
category = "individual",
|
|
11
11
|
} = {}) {
|
|
12
|
-
return
|
|
13
|
-
"
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
);
|
|
12
|
+
return $fetch<Record<string, any>>("/api/payment-methods/e-wallet", {
|
|
13
|
+
method: "POST",
|
|
14
|
+
body: {
|
|
15
|
+
customer_id,
|
|
16
|
+
type,
|
|
17
|
+
success_return_url,
|
|
18
|
+
failure_return_url,
|
|
19
|
+
cancel_return_url,
|
|
20
|
+
category,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
function linkCard({
|
|
@@ -37,7 +34,7 @@ export default function usePaymentMethod() {
|
|
|
37
34
|
failure_return_url = "",
|
|
38
35
|
subscriptionData = {},
|
|
39
36
|
} = {}) {
|
|
40
|
-
return
|
|
37
|
+
return $fetch<Record<string, any>>("/api/payment-methods/card", {
|
|
41
38
|
method: "POST",
|
|
42
39
|
body: {
|
|
43
40
|
cardType,
|
|
@@ -55,7 +52,7 @@ export default function usePaymentMethod() {
|
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
function getByUser(user = "") {
|
|
58
|
-
return
|
|
55
|
+
return $fetch<Array<Record<string, any>>>(
|
|
59
56
|
`/api/payment-methods/user/${user}`,
|
|
60
57
|
{
|
|
61
58
|
method: "GET",
|
|
@@ -64,7 +61,7 @@ export default function usePaymentMethod() {
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
function getByOrg(org = "") {
|
|
67
|
-
return
|
|
64
|
+
return $fetch<Array<Record<string, any>>>(
|
|
68
65
|
`/api/payment-methods/org/${org}`,
|
|
69
66
|
{
|
|
70
67
|
method: "GET",
|
|
@@ -73,15 +70,11 @@ export default function usePaymentMethod() {
|
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
function getById(id = "") {
|
|
76
|
-
return
|
|
77
|
-
`/api/payment-methods/id/${id}`
|
|
78
|
-
);
|
|
73
|
+
return $fetch<Record<string, any>>(`/api/payment-methods/id/${id}`);
|
|
79
74
|
}
|
|
80
75
|
|
|
81
76
|
function getByCustomerId(id = "") {
|
|
82
|
-
return
|
|
83
|
-
`/api/payment-methods/customer/${id}`
|
|
84
|
-
);
|
|
77
|
+
return $fetch<Record<string, any>>(`/api/payment-methods/customer/${id}`);
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
const eWalletNumber = useState("eWalletNumber", () => "");
|
|
@@ -94,13 +87,10 @@ export default function usePaymentMethod() {
|
|
|
94
87
|
const selectedPaymentMethod = useState("selectedPaymentMethod", () => "");
|
|
95
88
|
|
|
96
89
|
function linkOnly(value: Record<string, any>) {
|
|
97
|
-
return
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
body: value,
|
|
102
|
-
}
|
|
103
|
-
);
|
|
90
|
+
return $fetch<Record<string, any>>("/api/payment-methods/link-only", {
|
|
91
|
+
method: "POST",
|
|
92
|
+
body: value,
|
|
93
|
+
});
|
|
104
94
|
}
|
|
105
95
|
|
|
106
96
|
const supportedEwallets = [
|
|
@@ -308,13 +298,10 @@ export default function usePaymentMethod() {
|
|
|
308
298
|
}
|
|
309
299
|
|
|
310
300
|
function updateStatusById(id: string, status: string) {
|
|
311
|
-
return
|
|
312
|
-
|
|
313
|
-
{
|
|
314
|
-
|
|
315
|
-
body: { status },
|
|
316
|
-
}
|
|
317
|
-
);
|
|
301
|
+
return $fetch<Record<string, any>>(`/api/payment-methods/status/${id}`, {
|
|
302
|
+
method: "PATCH",
|
|
303
|
+
body: { status },
|
|
304
|
+
});
|
|
318
305
|
}
|
|
319
306
|
|
|
320
307
|
return {
|
|
@@ -50,6 +50,7 @@ export default function usePermission() {
|
|
|
50
50
|
const perm = ref<TPerm>({
|
|
51
51
|
app: "",
|
|
52
52
|
key: "",
|
|
53
|
+
name: "",
|
|
53
54
|
group: "",
|
|
54
55
|
description: "",
|
|
55
56
|
});
|
|
@@ -63,7 +64,7 @@ export default function usePermission() {
|
|
|
63
64
|
|
|
64
65
|
function updatePermById(
|
|
65
66
|
id: string,
|
|
66
|
-
value: Pick<TPerm, "key" | "group" | "description">
|
|
67
|
+
value: Pick<TPerm, "key" | "name" | "group" | "description">
|
|
67
68
|
) {
|
|
68
69
|
return $fetch(`/api/permissions/id/${id}`, {
|
|
69
70
|
method: "PATCH",
|
package/composables/usePrice.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export default function usePromoCode() {
|
|
2
2
|
function add(value: TPromoCode) {
|
|
3
|
-
return
|
|
3
|
+
return $fetch<Record<string, any>>("/api/promo-codes", {
|
|
4
4
|
method: "POST",
|
|
5
5
|
body: value,
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function getPromoCodes({ search = "", page = 1, status = "active" } = {}) {
|
|
10
|
-
return
|
|
10
|
+
return $fetch<Record<string, any>>("/api/promo-codes", {
|
|
11
11
|
method: "GET",
|
|
12
12
|
query: {
|
|
13
13
|
search,
|
|
@@ -18,7 +18,7 @@ export default function usePromoCode() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function getByCode(code: string, type?: string, assigned?: boolean) {
|
|
21
|
-
return
|
|
21
|
+
return $fetch<TPromoCode>("/api/promo-codes/code", {
|
|
22
22
|
method: "GET",
|
|
23
23
|
params: {
|
|
24
24
|
code,
|
|
@@ -29,7 +29,7 @@ export default function usePromoCode() {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function getById(id: string) {
|
|
32
|
-
return
|
|
32
|
+
return $fetch<TPromoCode>(`/api/promo-codes/id/${id}`, {
|
|
33
33
|
method: "GET",
|
|
34
34
|
});
|
|
35
35
|
}
|
package/composables/useRole.ts
CHANGED
|
@@ -1,89 +1,73 @@
|
|
|
1
1
|
export default function useRole() {
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
name: string;
|
|
5
|
-
permissions: Array<string>;
|
|
6
|
-
type: string;
|
|
7
|
-
org: string;
|
|
8
|
-
}
|
|
9
|
-
) {
|
|
10
|
-
return useNuxtApp().$api("/api/roles", {
|
|
2
|
+
function add(value: Pick<TRole, "name" | "permissions" | "type" | "org">) {
|
|
3
|
+
return $fetch("/api/roles", {
|
|
11
4
|
method: "POST",
|
|
12
|
-
body:
|
|
5
|
+
body: value,
|
|
13
6
|
});
|
|
14
7
|
}
|
|
15
8
|
|
|
16
|
-
function
|
|
9
|
+
function getAll({
|
|
17
10
|
search = "",
|
|
18
11
|
page = 1,
|
|
19
12
|
limit = 20,
|
|
20
13
|
type = "",
|
|
21
14
|
org = "",
|
|
22
15
|
} = {}) {
|
|
23
|
-
return
|
|
16
|
+
return $fetch<Record<string, any>>("/api/roles", {
|
|
24
17
|
method: "GET",
|
|
25
18
|
query: { search, page, limit, type, org },
|
|
26
19
|
});
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
function
|
|
30
|
-
return
|
|
22
|
+
function getById(id: string) {
|
|
23
|
+
return $fetch<Record<string, any>>(`/api/roles/id/${id}`, {
|
|
31
24
|
method: "GET",
|
|
32
25
|
});
|
|
33
26
|
}
|
|
34
27
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
name?: string,
|
|
38
|
-
permissions?: Array<string>
|
|
39
|
-
) {
|
|
40
|
-
return useNuxtApp().$api(`/api/roles/id/${_id}`, {
|
|
28
|
+
function updateById(id: string, value: Pick<TRole, "name" | "permissions">) {
|
|
29
|
+
return $fetch(`/api/roles/id/${id}`, {
|
|
41
30
|
method: "PATCH",
|
|
42
|
-
body:
|
|
31
|
+
body: value,
|
|
43
32
|
});
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
function updatePermissionById(_id: string, permissions?: Array<string>) {
|
|
47
|
-
return
|
|
36
|
+
return $fetch(`/api/roles/permissions/id/${_id}`, {
|
|
48
37
|
method: "PATCH",
|
|
49
38
|
body: { permissions },
|
|
50
39
|
});
|
|
51
40
|
}
|
|
52
41
|
|
|
53
42
|
function updateRoleFieldById(_id: string, field: string, value: string) {
|
|
54
|
-
return
|
|
43
|
+
return $fetch(`/api/roles/${_id}`, {
|
|
55
44
|
method: "PATCH",
|
|
56
45
|
body: { field, value },
|
|
57
46
|
});
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
function
|
|
61
|
-
return
|
|
49
|
+
function deleteById(_id: string) {
|
|
50
|
+
return $fetch<Record<string, any>>(`/api/roles/${_id}`, {
|
|
62
51
|
method: "DELETE",
|
|
63
52
|
});
|
|
64
53
|
}
|
|
65
54
|
|
|
66
|
-
const role =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
createdAt: "",
|
|
73
|
-
updatedAt: "",
|
|
74
|
-
deletedAt: "",
|
|
75
|
-
default: false,
|
|
76
|
-
};
|
|
55
|
+
const role = ref<TRole>({
|
|
56
|
+
name: "",
|
|
57
|
+
org: "",
|
|
58
|
+
permissions: [],
|
|
59
|
+
type: "",
|
|
60
|
+
description: "",
|
|
77
61
|
});
|
|
78
62
|
|
|
79
63
|
return {
|
|
80
64
|
role,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
add,
|
|
66
|
+
getAll,
|
|
67
|
+
getById,
|
|
68
|
+
updateById,
|
|
85
69
|
updateRoleFieldById,
|
|
86
|
-
|
|
70
|
+
deleteById,
|
|
87
71
|
updatePermissionById,
|
|
88
72
|
};
|
|
89
73
|
}
|
|
@@ -4,7 +4,7 @@ export default function useSubscription() {
|
|
|
4
4
|
trialDays: number,
|
|
5
5
|
productId: string
|
|
6
6
|
) {
|
|
7
|
-
return
|
|
7
|
+
return $fetch("/api/subscriptions/plan", {
|
|
8
8
|
method: "POST",
|
|
9
9
|
body: {
|
|
10
10
|
seats,
|
|
@@ -15,7 +15,7 @@ export default function useSubscription() {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function add(subscriptionId: string, user: string) {
|
|
18
|
-
return
|
|
18
|
+
return $fetch("/api/subscriptions", {
|
|
19
19
|
method: "POST",
|
|
20
20
|
body: {
|
|
21
21
|
subscriptionId,
|
|
@@ -25,7 +25,7 @@ export default function useSubscription() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function addBillingContactById(id: string, email: string) {
|
|
28
|
-
return
|
|
28
|
+
return $fetch(`/api/subscriptions/billing-contact/${id}`, {
|
|
29
29
|
method: "PUT",
|
|
30
30
|
body: {
|
|
31
31
|
email,
|
|
@@ -38,7 +38,7 @@ export default function useSubscription() {
|
|
|
38
38
|
addedAt: string,
|
|
39
39
|
email: string
|
|
40
40
|
) {
|
|
41
|
-
return
|
|
41
|
+
return $fetch(
|
|
42
42
|
`/api/subscriptions/billing-contact/${id}/added-at/${addedAt}`,
|
|
43
43
|
{
|
|
44
44
|
method: "PUT",
|
|
@@ -50,7 +50,7 @@ export default function useSubscription() {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function deleteBillingContactByAddedAt(id: string, addedAt: string) {
|
|
53
|
-
return
|
|
53
|
+
return $fetch(
|
|
54
54
|
`/api/subscriptions/billing-contact/${id}/added-at/${addedAt}`,
|
|
55
55
|
{
|
|
56
56
|
method: "DELETE",
|
|
@@ -59,33 +59,27 @@ export default function useSubscription() {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function getById(id: string) {
|
|
62
|
-
return
|
|
62
|
+
return $fetch<TSubscription>(`/api/subscriptions/id/${id}`);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function getByAffiliateId(id: string) {
|
|
66
|
-
return
|
|
67
|
-
`/api/subscriptions/affiliate/${id}`
|
|
68
|
-
);
|
|
66
|
+
return $fetch<TSubscription>(`/api/subscriptions/affiliate/${id}`);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
function getByOrgId(id: string) {
|
|
72
|
-
return
|
|
73
|
-
`/api/subscriptions/org/${id}`
|
|
74
|
-
);
|
|
70
|
+
return $fetch<Record<string, any>>(`/api/subscriptions/org/${id}`);
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
function getSubscriptions() {
|
|
78
|
-
return
|
|
74
|
+
return $fetch("/api/subscriptions");
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
function getSubscriptionStatusById(id: string) {
|
|
82
|
-
return
|
|
83
|
-
`/api/subscriptions/status/${id}`
|
|
84
|
-
);
|
|
78
|
+
return $fetch<Record<string, string>>(`/api/subscriptions/status/${id}`);
|
|
85
79
|
}
|
|
86
80
|
|
|
87
81
|
function cancelSubscription(id: string) {
|
|
88
|
-
return
|
|
82
|
+
return $fetch(`/api/subscriptions/cancel/${id}`, {
|
|
89
83
|
method: "DELETE",
|
|
90
84
|
});
|
|
91
85
|
}
|
|
@@ -96,7 +90,7 @@ export default function useSubscription() {
|
|
|
96
90
|
);
|
|
97
91
|
|
|
98
92
|
function updatePromoCodeById(id: string, promoCode: string) {
|
|
99
|
-
return
|
|
93
|
+
return $fetch(`/api/subscriptions/promo-code/${id}`, {
|
|
100
94
|
method: "PUT",
|
|
101
95
|
body: {
|
|
102
96
|
promoCode,
|
|
@@ -105,7 +99,7 @@ export default function useSubscription() {
|
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
function updateStatusById(id: string, status: string) {
|
|
108
|
-
return
|
|
102
|
+
return $fetch(`/api/subscriptions/status/${id}`, {
|
|
109
103
|
method: "PUT",
|
|
110
104
|
body: {
|
|
111
105
|
status,
|
|
@@ -114,7 +108,7 @@ export default function useSubscription() {
|
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
function updatePaymentMethodById(id: string, paymentMethodId: string) {
|
|
117
|
-
return
|
|
111
|
+
return $fetch(`/api/subscriptions/payment-method/${id}`, {
|
|
118
112
|
method: "PUT",
|
|
119
113
|
body: {
|
|
120
114
|
paymentMethodId,
|
|
@@ -168,23 +162,17 @@ export default function useSubscription() {
|
|
|
168
162
|
};
|
|
169
163
|
|
|
170
164
|
function initOrgSubscription(value: TSub) {
|
|
171
|
-
return
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
body: value,
|
|
176
|
-
}
|
|
177
|
-
);
|
|
165
|
+
return $fetch<Record<string, any>>("/api/subscriptions/organization", {
|
|
166
|
+
method: "POST",
|
|
167
|
+
body: value,
|
|
168
|
+
});
|
|
178
169
|
}
|
|
179
170
|
|
|
180
171
|
function initAffiliateSubscription(value: TSub) {
|
|
181
|
-
return
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
body: value,
|
|
186
|
-
}
|
|
187
|
-
);
|
|
172
|
+
return $fetch<Record<string, any>>("/api/subscriptions/affiliate", {
|
|
173
|
+
method: "POST",
|
|
174
|
+
body: value,
|
|
175
|
+
});
|
|
188
176
|
}
|
|
189
177
|
|
|
190
178
|
function updateSeatsById({
|
|
@@ -193,7 +181,7 @@ export default function useSubscription() {
|
|
|
193
181
|
seats = 0,
|
|
194
182
|
amount = 0,
|
|
195
183
|
} = {}) {
|
|
196
|
-
return
|
|
184
|
+
return $fetch<Record<string, any>>(
|
|
197
185
|
`/api/subscriptions/seats/${subscriptionId}`,
|
|
198
186
|
{
|
|
199
187
|
method: "PUT",
|
|
@@ -207,7 +195,7 @@ export default function useSubscription() {
|
|
|
207
195
|
}
|
|
208
196
|
|
|
209
197
|
function processSubscriptionPayment(id: string, invoice: string) {
|
|
210
|
-
return
|
|
198
|
+
return $fetch(`/api/subscriptions/payment/id/${id}`, {
|
|
211
199
|
method: "PUT",
|
|
212
200
|
body: {
|
|
213
201
|
invoice,
|
|
@@ -230,7 +218,7 @@ export default function useSubscription() {
|
|
|
230
218
|
type: string;
|
|
231
219
|
};
|
|
232
220
|
}) {
|
|
233
|
-
return
|
|
221
|
+
return $fetch("/api/subscriptions/subscribe", {
|
|
234
222
|
method: "POST",
|
|
235
223
|
body: value,
|
|
236
224
|
});
|
package/composables/useUser.ts
CHANGED
|
@@ -7,49 +7,49 @@ export default function useUser() {
|
|
|
7
7
|
org = "",
|
|
8
8
|
orgName = "",
|
|
9
9
|
} = {}) {
|
|
10
|
-
return
|
|
10
|
+
return $fetch<Record<string, any>>("/api/auth/invite", {
|
|
11
11
|
method: "POST",
|
|
12
12
|
body: { email, app, role, roleName, org, orgName },
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function updateName({ firstName = "", lastName = "" } = {}) {
|
|
17
|
-
return
|
|
17
|
+
return $fetch<Record<string, any>>("/api/users/name", {
|
|
18
18
|
method: "PUT",
|
|
19
19
|
body: { firstName, lastName },
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function updateBirthday({ month = "", day = 0, year = 0 } = {}) {
|
|
24
|
-
return
|
|
24
|
+
return $fetch<Record<string, any>>("/api/users/birthday", {
|
|
25
25
|
method: "PUT",
|
|
26
26
|
body: { month, day, year },
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function updateGender(gender = "") {
|
|
31
|
-
return
|
|
31
|
+
return $fetch<Record<string, any>>("/api/users/gender", {
|
|
32
32
|
method: "PUT",
|
|
33
33
|
body: { gender },
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function updateEmail(email = "") {
|
|
38
|
-
return
|
|
38
|
+
return $fetch<Record<string, any>>("/api/users/email", {
|
|
39
39
|
method: "PUT",
|
|
40
40
|
body: { email },
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function updateContact(contact = "") {
|
|
45
|
-
return
|
|
45
|
+
return $fetch<Record<string, any>>("/api/users/contact", {
|
|
46
46
|
method: "PUT",
|
|
47
47
|
body: { contact },
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function updateUserFieldById(id = "", field = "", value = "") {
|
|
52
|
-
return
|
|
52
|
+
return $fetch<Record<string, any>>(`/api/users/field/${id}`, {
|
|
53
53
|
method: "PATCH",
|
|
54
54
|
body: { field, value },
|
|
55
55
|
});
|
|
@@ -61,14 +61,14 @@ export default function useUser() {
|
|
|
61
61
|
search = "",
|
|
62
62
|
page = 1,
|
|
63
63
|
} = {}) {
|
|
64
|
-
return
|
|
64
|
+
return $fetch<Record<string, any>>("/api/users", {
|
|
65
65
|
method: "GET",
|
|
66
66
|
query: { status, search, page, type },
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function getById(id = "") {
|
|
71
|
-
return
|
|
71
|
+
return $fetch<Record<string, any>>(`/api/users/id/${id}`, {
|
|
72
72
|
method: "GET",
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -81,7 +81,7 @@ export default function useUser() {
|
|
|
81
81
|
referralCode = "",
|
|
82
82
|
type = "",
|
|
83
83
|
} = {}) {
|
|
84
|
-
return
|
|
84
|
+
return $fetch<Record<string, any>>(`/api/users/invite/${id}`, {
|
|
85
85
|
method: "POST",
|
|
86
86
|
body: { firstName, lastName, password, referralCode, type },
|
|
87
87
|
});
|
package/composables/useUtils.ts
CHANGED
|
@@ -140,7 +140,7 @@ export default function useUtils() {
|
|
|
140
140
|
|
|
141
141
|
async function getCountries() {
|
|
142
142
|
try {
|
|
143
|
-
const countries = await
|
|
143
|
+
const countries = await $fetch<Array<Record<string, any>>>(
|
|
144
144
|
"https://restcountries.com/v3.1/all?fields=name,currencies,idd",
|
|
145
145
|
{ method: "GET" }
|
|
146
146
|
);
|
|
@@ -7,7 +7,7 @@ export default function useUser() {
|
|
|
7
7
|
email = "",
|
|
8
8
|
app = "",
|
|
9
9
|
} = {}) {
|
|
10
|
-
return
|
|
10
|
+
return $fetch<Record<string, any>>("/api/verifications", {
|
|
11
11
|
method: "GET",
|
|
12
12
|
query: { status, search, page, type, email, app },
|
|
13
13
|
});
|
package/package.json
CHANGED
package/plugins/API.ts
CHANGED
package/plugins/member.client.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export default defineNuxtPlugin(() => {
|
|
2
2
|
const router = useRouter();
|
|
3
3
|
const { getByUserType } = useMember();
|
|
4
|
-
const { getRoleById } = useRole();
|
|
4
|
+
const { getById: getRoleById } = useRole();
|
|
5
5
|
const { membership, permissions } = useLocalAuth();
|
|
6
6
|
|
|
7
|
-
router.afterEach((to) => {
|
|
7
|
+
router.afterEach(async (to) => {
|
|
8
8
|
const isSecured = to.meta?.member;
|
|
9
9
|
if (!isSecured) return;
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ export default defineNuxtPlugin(() => {
|
|
|
17
17
|
data: userMemberData,
|
|
18
18
|
error: userMemberError,
|
|
19
19
|
refresh: refreshUserMemberData,
|
|
20
|
-
} = useLazyAsyncData(
|
|
20
|
+
} = await useLazyAsyncData(
|
|
21
21
|
"plugin-get-member-by-id" + userId,
|
|
22
22
|
() => getByUserType(userId, APP, org),
|
|
23
23
|
{ immediate: false }
|
|
@@ -43,7 +43,7 @@ export default defineNuxtPlugin(() => {
|
|
|
43
43
|
|
|
44
44
|
const roleId = computed(() => membership.value?.role ?? "");
|
|
45
45
|
|
|
46
|
-
const { data: roleData, refresh: refreshRoleData } = useLazyAsyncData(
|
|
46
|
+
const { data: roleData, refresh: refreshRoleData } = await useLazyAsyncData(
|
|
47
47
|
"plugin-get-role-by-id" + roleId.value,
|
|
48
48
|
() => getRoleById(roleId.value),
|
|
49
49
|
{ immediate: false }
|