@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.
@@ -1,6 +1,6 @@
1
1
  export default function useOrg() {
2
2
  function getAll({ page = 1, search = "", limit = 20, status = "" } = {}) {
3
- return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
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 useNuxtApp().$api<Record<string, any>>(
16
- `/api/organizations/id/${id}`,
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 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
- );
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 useNuxtApp().$api<TOrg>(`/api/organizations/name/${name}`, {
74
+ return $fetch<TOrg>(`/api/organizations/name/${name}`, {
81
75
  method: "GET",
82
76
  });
83
77
  }
@@ -5,7 +5,7 @@ export default function usePayment() {
5
5
  page = 1,
6
6
  status = "completed",
7
7
  } = {}) {
8
- return useNuxtApp().$api<Record<string, any>>("/api/payments", {
8
+ return $fetch<Record<string, any>>("/api/payments", {
9
9
  method: "GET",
10
10
  query: {
11
11
  search,
@@ -9,20 +9,17 @@ export default function usePaymentMethod() {
9
9
  cancel_return_url = "",
10
10
  category = "individual",
11
11
  } = {}) {
12
- return useNuxtApp().$api<Record<string, any>>(
13
- "/api/payment-methods/e-wallet",
14
- {
15
- method: "POST",
16
- body: {
17
- customer_id,
18
- type,
19
- success_return_url,
20
- failure_return_url,
21
- cancel_return_url,
22
- category,
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 useNuxtApp().$api<Record<string, any>>("/api/payment-methods/card", {
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 useNuxtApp().$api<Array<Record<string, any>>>(
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 useNuxtApp().$api<Array<Record<string, any>>>(
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 useNuxtApp().$api<Record<string, any>>(
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 useNuxtApp().$api<Record<string, any>>(
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 useNuxtApp().$api<Record<string, any>>(
98
- "/api/payment-methods/link-only",
99
- {
100
- method: "POST",
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 useNuxtApp().$api<Record<string, any>>(
312
- `/api/payment-methods/status/${id}`,
313
- {
314
- method: "PATCH",
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",
@@ -1,6 +1,6 @@
1
1
  export default function usePrice() {
2
2
  function getByNameType(name: string, type: string) {
3
- return useNuxtApp().$api<Record<string, any>>("/api/prices/price", {
3
+ return $fetch<Record<string, any>>("/api/prices/price", {
4
4
  method: "GET",
5
5
  params: {
6
6
  name,
@@ -1,13 +1,13 @@
1
1
  export default function usePromoCode() {
2
2
  function add(value: TPromoCode) {
3
- return useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
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 useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
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 useNuxtApp().$api<TPromoCode>("/api/promo-codes/code", {
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 useNuxtApp().$api<TPromoCode>(`/api/promo-codes/id/${id}`, {
32
+ return $fetch<TPromoCode>(`/api/promo-codes/id/${id}`, {
33
33
  method: "GET",
34
34
  });
35
35
  }
@@ -1,89 +1,73 @@
1
1
  export default function useRole() {
2
- function createRole(
3
- { name, permissions, type, org } = {} as {
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: { name, permissions, type, org },
5
+ body: value,
13
6
  });
14
7
  }
15
8
 
16
- function getRoles({
9
+ function getAll({
17
10
  search = "",
18
11
  page = 1,
19
12
  limit = 20,
20
13
  type = "",
21
14
  org = "",
22
15
  } = {}) {
23
- return useNuxtApp().$api<Record<string, any>>("/api/roles", {
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 getRoleById(id: string) {
30
- return useNuxtApp().$api<Record<string, any>>(`/api/roles/id/${id}`, {
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 updateRoleById(
36
- _id: string,
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: { name, permissions },
31
+ body: value,
43
32
  });
44
33
  }
45
34
 
46
35
  function updatePermissionById(_id: string, permissions?: Array<string>) {
47
- return useNuxtApp().$api(`/api/roles/permissions/id/${_id}`, {
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 useNuxtApp().$api(`/api/roles/${_id}`, {
43
+ return $fetch(`/api/roles/${_id}`, {
55
44
  method: "PATCH",
56
45
  body: { field, value },
57
46
  });
58
47
  }
59
48
 
60
- function deleteRole(_id: string) {
61
- return useNuxtApp().$api<Record<string, any>>(`/api/roles/${_id}`, {
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 = useState("userRole", (): TRole => {
67
- return {
68
- _id: "",
69
- name: "",
70
- org: "",
71
- permissions: [],
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
- createRole,
82
- getRoles,
83
- getRoleById,
84
- updateRoleById,
65
+ add,
66
+ getAll,
67
+ getById,
68
+ updateById,
85
69
  updateRoleFieldById,
86
- deleteRole,
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 useNuxtApp().$api("/api/subscriptions/plan", {
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 useNuxtApp().$api("/api/subscriptions", {
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 useNuxtApp().$api(`/api/subscriptions/billing-contact/${id}`, {
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 useNuxtApp().$api(
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 useNuxtApp().$api(
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 useNuxtApp().$api<TSubscription>(`/api/subscriptions/id/${id}`);
62
+ return $fetch<TSubscription>(`/api/subscriptions/id/${id}`);
63
63
  }
64
64
 
65
65
  function getByAffiliateId(id: string) {
66
- return useNuxtApp().$api<TSubscription>(
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 useNuxtApp().$api<Record<string, any>>(
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 useNuxtApp().$api("/api/subscriptions");
74
+ return $fetch("/api/subscriptions");
79
75
  }
80
76
 
81
77
  function getSubscriptionStatusById(id: string) {
82
- return useNuxtApp().$api<Record<string, string>>(
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 useNuxtApp().$api(`/api/subscriptions/cancel/${id}`, {
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 useNuxtApp().$api(`/api/subscriptions/promo-code/${id}`, {
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 useNuxtApp().$api(`/api/subscriptions/status/${id}`, {
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 useNuxtApp().$api(`/api/subscriptions/payment-method/${id}`, {
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 useNuxtApp().$api<Record<string, any>>(
172
- "/api/subscriptions/organization",
173
- {
174
- method: "POST",
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 useNuxtApp().$api<Record<string, any>>(
182
- "/api/subscriptions/affiliate",
183
- {
184
- method: "POST",
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 useNuxtApp().$api<Record<string, any>>(
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 useNuxtApp().$api(`/api/subscriptions/payment/id/${id}`, {
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 useNuxtApp().$api("/api/subscriptions/subscribe", {
221
+ return $fetch("/api/subscriptions/subscribe", {
234
222
  method: "POST",
235
223
  body: value,
236
224
  });
@@ -7,49 +7,49 @@ export default function useUser() {
7
7
  org = "",
8
8
  orgName = "",
9
9
  } = {}) {
10
- return useNuxtApp().$api<Record<string, any>>("/api/auth/invite", {
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 useNuxtApp().$api<Record<string, any>>("/api/users/name", {
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 useNuxtApp().$api<Record<string, any>>("/api/users/birthday", {
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 useNuxtApp().$api<Record<string, any>>("/api/users/gender", {
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 useNuxtApp().$api<Record<string, any>>("/api/users/email", {
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 useNuxtApp().$api<Record<string, any>>("/api/users/contact", {
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 useNuxtApp().$api<Record<string, any>>(`/api/users/field/${id}`, {
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 useNuxtApp().$api<Record<string, any>>("/api/users", {
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 useNuxtApp().$api<Record<string, any>>(`/api/users/id/${id}`, {
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 useNuxtApp().$api<Record<string, any>>(`/api/users/invite/${id}`, {
84
+ return $fetch<Record<string, any>>(`/api/users/invite/${id}`, {
85
85
  method: "POST",
86
86
  body: { firstName, lastName, password, referralCode, type },
87
87
  });
@@ -140,7 +140,7 @@ export default function useUtils() {
140
140
 
141
141
  async function getCountries() {
142
142
  try {
143
- const countries = await useNuxtApp().$api<Array<Record<string, any>>>(
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 useNuxtApp().$api<Record<string, any>>("/api/verifications", {
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
@@ -2,7 +2,7 @@
2
2
  "name": "@goweekdays/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.2.4",
5
+ "version": "1.2.5",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
package/plugins/API.ts CHANGED
@@ -48,7 +48,7 @@ export default defineNuxtPlugin(() => {
48
48
  return useFetch(path, options);
49
49
  };
50
50
 
51
- // Expose to useNuxtApp().$api
51
+ // Expose to $fetch
52
52
  return {
53
53
  provide: {
54
54
  api,
@@ -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 }