@goweekdays/layer-common 1.5.0 → 1.5.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @goweekdays/layer-common
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 4390428: Add default props for VCombobox in Vuetify plugin
8
+ - 0304ef9: Refactor API calls to use $api from Nuxt plugin
9
+
3
10
  ## 1.5.0
4
11
 
5
12
  ### Minor Changes
@@ -13,7 +13,7 @@ export default function useAddress() {
13
13
  postalCode = "",
14
14
  taxId = "",
15
15
  } = {}) {
16
- return $fetch("/api/addresses", {
16
+ return useNuxtApp().$api("/api/addresses", {
17
17
  method: "POST",
18
18
  body: {
19
19
  type,
@@ -57,18 +57,18 @@ export default function useAddress() {
57
57
  payload.org = orgId;
58
58
  }
59
59
 
60
- return $fetch(`/api/addresses/details/${id}`, {
60
+ return useNuxtApp().$api(`/api/addresses/details/${id}`, {
61
61
  method: "PUT",
62
62
  body: payload,
63
63
  });
64
64
  }
65
65
 
66
66
  function getByUserId(user = "") {
67
- return $fetch<TAddress>(`/api/addresses/user/${user}`);
67
+ return useNuxtApp().$api<TAddress>(`/api/addresses/user/${user}`);
68
68
  }
69
69
 
70
70
  function getByOrgId(id = "") {
71
- return $fetch<TAddress>(`/api/addresses/org/${id}`);
71
+ return useNuxtApp().$api<TAddress>(`/api/addresses/org/${id}`);
72
72
  }
73
73
 
74
74
  const _address = useState("address", (): TAddress => {
@@ -13,7 +13,7 @@ export default function useApps() {
13
13
  const resource = "/api/apps";
14
14
 
15
15
  function add(value: TApp) {
16
- return $fetch(resource, {
16
+ return useNuxtApp().$api(resource, {
17
17
  method: "POST",
18
18
  body: value,
19
19
  });
@@ -26,7 +26,7 @@ export default function useApps() {
26
26
  status = "active",
27
27
  type = "standard",
28
28
  } = {}) {
29
- return $fetch<Record<string, any>>(resource, {
29
+ return useNuxtApp().$api<Record<string, any>>(resource, {
30
30
  method: "GET",
31
31
  query: { page, limit, search, status, type },
32
32
  });
@@ -36,14 +36,14 @@ export default function useApps() {
36
36
  id: string,
37
37
  value: { name: string; description: string }
38
38
  ) {
39
- return $fetch(`${resource}/id/${id}`, {
39
+ return useNuxtApp().$api(`${resource}/id/${id}`, {
40
40
  method: "PATCH",
41
41
  body: value,
42
42
  });
43
43
  }
44
44
 
45
45
  function deleteById(id: string) {
46
- return $fetch(`${resource}/id/${id}`, {
46
+ return useNuxtApp().$api(`${resource}/id/${id}`, {
47
47
  method: "DELETE",
48
48
  });
49
49
  }
@@ -7,7 +7,7 @@ export default function useChartOfAccount() {
7
7
  children?: number;
8
8
  }
9
9
  ) {
10
- return $fetch<Record<string, any>>("/api/chart-of-accounts", {
10
+ return useNuxtApp().$api<Record<string, any>>("/api/chart-of-accounts", {
11
11
  method: "GET",
12
12
  query: { page, status, orgId, children },
13
13
  });
@@ -23,30 +23,35 @@ export default function useChartOfAccount() {
23
23
  };
24
24
 
25
25
  function add(value: TAddPayload) {
26
- return $fetch<TAddPayload>("/api/chart-of-accounts", {
26
+ return useNuxtApp().$api<TAddPayload>("/api/chart-of-accounts", {
27
27
  method: "POST",
28
28
  body: value,
29
29
  });
30
30
  }
31
31
 
32
32
  function getById(id: string) {
33
- return $fetch<Record<string, any>>(`/api/chart-of-accounts/id/${id}`);
33
+ return useNuxtApp().$api<Record<string, any>>(
34
+ `/api/chart-of-accounts/id/${id}`
35
+ );
34
36
  }
35
37
 
36
38
  function updateById(
37
39
  id: string,
38
40
  value: Pick<TAddPayload, "name" | "code" | "normalBalance" | "parent">
39
41
  ) {
40
- return $fetch<TAddPayload>(`/api/chart-of-accounts/id/${id}`, {
42
+ return useNuxtApp().$api<TAddPayload>(`/api/chart-of-accounts/id/${id}`, {
41
43
  method: "PUT",
42
44
  body: value,
43
45
  });
44
46
  }
45
47
 
46
48
  function deleteById(id: string) {
47
- return $fetch<Record<string, any>>(`/api/chart-of-accounts/id/${id}`, {
48
- method: "DELETE",
49
- });
49
+ return useNuxtApp().$api<Record<string, any>>(
50
+ `/api/chart-of-accounts/id/${id}`,
51
+ {
52
+ method: "DELETE",
53
+ }
54
+ );
50
55
  }
51
56
 
52
57
  return {
@@ -7,16 +7,19 @@ export default function useFile() {
7
7
  const formData = new FormData();
8
8
  formData.append("file", file);
9
9
 
10
- return $fetch<Record<string, any>>("/api/files", {
10
+ return useNuxtApp().$api<Record<string, any>>("/api/files", {
11
11
  method: "POST",
12
12
  body: formData,
13
13
  });
14
14
  }
15
15
 
16
16
  function deleteFile(attachmentId: string) {
17
- return $fetch<Record<string, any>>(`/api/files/${attachmentId}`, {
18
- method: "DELETE",
19
- });
17
+ return useNuxtApp().$api<Record<string, any>>(
18
+ `/api/files/${attachmentId}`,
19
+ {
20
+ method: "DELETE",
21
+ }
22
+ );
20
23
  }
21
24
 
22
25
  return {
@@ -4,23 +4,29 @@ export default function useInvoice() {
4
4
  throw new Error("Subscription ID is required");
5
5
  }
6
6
 
7
- return $fetch<Record<string, any>>(`/api/invoices/subscription/${id}`, {
8
- method: "GET",
9
- params: {
10
- search,
11
- page,
12
- },
13
- });
7
+ return useNuxtApp().$api<Record<string, any>>(
8
+ `/api/invoices/subscription/${id}`,
9
+ {
10
+ method: "GET",
11
+ params: {
12
+ search,
13
+ page,
14
+ },
15
+ }
16
+ );
14
17
  }
15
18
 
16
19
  function getByNumber(number: string) {
17
- return $fetch<Record<string, any>>(`/api/invoices/number/${number}`, {
18
- method: "GET",
19
- });
20
+ return useNuxtApp().$api<Record<string, any>>(
21
+ `/api/invoices/number/${number}`,
22
+ {
23
+ method: "GET",
24
+ }
25
+ );
20
26
  }
21
27
 
22
28
  function getByDueDateStatus(date: string, status: string) {
23
- return $fetch<Record<string, any>>(
29
+ return useNuxtApp().$api<Record<string, any>>(
24
30
  `/api/invoices/due-date/${date}/status/${status}`,
25
31
  {
26
32
  method: "GET",
@@ -0,0 +1,67 @@
1
+ export function useJobPost() {
2
+ const jobPost = ref<TJobPost>({
3
+ title: "",
4
+ org: "",
5
+ setup: "",
6
+ location: "",
7
+ type: "",
8
+ description: "",
9
+ });
10
+
11
+ function getAll({ page = 1, limit = 50, search = "" } = {}) {
12
+ return useNuxtApp().$api<Record<string, any>>(`/api/job/posts`, {
13
+ method: "GET",
14
+ query: {
15
+ page,
16
+ limit,
17
+ search,
18
+ },
19
+ });
20
+ }
21
+
22
+ function getJobPostsByOrg(
23
+ id: any,
24
+ { page = 1, search = "", status = "draft", limit = 10, org = "" } = {}
25
+ ) {
26
+ return useNuxtApp().$api<Record<string, any>>(`/api/job/posts/${id}`, {
27
+ method: "GET",
28
+ query: {
29
+ page,
30
+ search,
31
+ limit,
32
+ status,
33
+ org,
34
+ },
35
+ });
36
+ }
37
+
38
+ function getJobPostsById(id: any) {
39
+ return useNuxtApp().$api<Record<string, any>>(`/api/job/posts/id/${id}`, {
40
+ method: "GET",
41
+ });
42
+ }
43
+
44
+ function deleteJobPostById(id: any) {
45
+ return useNuxtApp().$api<Record<string, any>>(`/api/job/posts/id/${id}`, {
46
+ method: "DELETE",
47
+ });
48
+ }
49
+
50
+ function updateJobPostStatusById(id: any, status: any) {
51
+ return useNuxtApp().$api<Record<string, any>>(
52
+ `/api/job/posts/id/${id}/status/${status}`,
53
+ {
54
+ method: "PATCH",
55
+ }
56
+ );
57
+ }
58
+
59
+ return {
60
+ jobPost,
61
+ getAll,
62
+ getJobPostsByOrg,
63
+ getJobPostsById,
64
+ deleteJobPostById,
65
+ updateJobPostStatusById,
66
+ };
67
+ }
@@ -1,6 +1,6 @@
1
1
  export default function useLedgerBilling() {
2
2
  function getAll({ org = "", search = "", page = 1, status = "" } = {}) {
3
- return $fetch<Record<string, any>>("/api/ledger/billings", {
3
+ return useNuxtApp().$api<Record<string, any>>("/api/ledger/billings", {
4
4
  method: "GET",
5
5
  query: {
6
6
  org,
@@ -12,13 +12,16 @@ export default function useLedgerBilling() {
12
12
  }
13
13
 
14
14
  function getById(id = "") {
15
- return $fetch<Record<string, any>>(`/api/ledger/billings/id/${id}`, {
16
- method: "GET",
17
- });
15
+ return useNuxtApp().$api<Record<string, any>>(
16
+ `/api/ledger/billings/id/${id}`,
17
+ {
18
+ method: "GET",
19
+ }
20
+ );
18
21
  }
19
22
 
20
23
  function getSummary(org = "", status = "") {
21
- return $fetch<Record<string, any>>(
24
+ return useNuxtApp().$api<Record<string, any>>(
22
25
  `/api/ledger/billings/summary/org/${org}/status/${status}`,
23
26
  {
24
27
  method: "GET",
@@ -13,7 +13,7 @@ export default function useLocalAuth() {
13
13
  };
14
14
 
15
15
  async function login({ email = "", password = "", role = "" }) {
16
- return $fetch<Record<string, any>>("/api/auth/login", {
16
+ return useNuxtApp().$api<Record<string, any>>("/api/auth/login", {
17
17
  method: "POST",
18
18
  body: JSON.stringify({ email, password, role }),
19
19
  });
@@ -29,7 +29,7 @@ export default function useLocalAuth() {
29
29
  const user = useCookie("user", cookieConfig).value;
30
30
  if (!user) return null;
31
31
  try {
32
- const _user = await $fetch<TUser>(`/api/users/id/${user}`, {
32
+ const _user = await useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
33
33
  method: "GET",
34
34
  });
35
35
 
@@ -41,14 +41,17 @@ export default function useLocalAuth() {
41
41
  }
42
42
 
43
43
  async function forgotPassword(email: string) {
44
- return $fetch<Record<string, any>>("/api/verifications/forget-password", {
45
- method: "POST",
46
- body: JSON.stringify({ email }),
47
- });
44
+ return useNuxtApp().$api<Record<string, any>>(
45
+ "/api/verifications/forget-password",
46
+ {
47
+ method: "POST",
48
+ body: JSON.stringify({ email }),
49
+ }
50
+ );
48
51
  }
49
52
 
50
53
  function verify(id: string) {
51
- return $fetch<Record<string, any>>(`/api/auth/verify/${id}`, {
54
+ return useNuxtApp().$api<Record<string, any>>(`/api/auth/verify/${id}`, {
52
55
  method: "GET",
53
56
  });
54
57
  }
@@ -16,18 +16,18 @@ export default function useMember() {
16
16
  });
17
17
 
18
18
  function getByUserId(user: string) {
19
- return $fetch<TMember>(`/api/members/user/${user}`);
19
+ return useNuxtApp().$api<TMember>(`/api/members/user/${user}`);
20
20
  }
21
21
 
22
22
  function getByUserType(user: string, type: string, org?: string) {
23
- return $fetch<TMember>(`/api/members/user/${user}/app/${type}`, {
23
+ return useNuxtApp().$api<TMember>(`/api/members/user/${user}/app/${type}`, {
24
24
  method: "GET",
25
25
  query: { org },
26
26
  });
27
27
  }
28
28
 
29
29
  function getByApp({ app = "", user = "", org = "" } = {}) {
30
- return $fetch<TMember>(`/api/members/app/${app}/user/${user}`, {
30
+ return useNuxtApp().$api<TMember>(`/api/members/app/${app}/user/${user}`, {
31
31
  method: "GET",
32
32
  query: { org },
33
33
  });
@@ -40,7 +40,7 @@ export default function useMember() {
40
40
  page = 1,
41
41
  search = "",
42
42
  } = {}) {
43
- return $fetch<Record<string, any>>(
43
+ return useNuxtApp().$api<Record<string, any>>(
44
44
  `/api/members/orgs/app/${app}/user/${user}`,
45
45
  {
46
46
  method: "GET",
@@ -58,7 +58,7 @@ export default function useMember() {
58
58
  app = "",
59
59
  status = "active",
60
60
  } = {}) {
61
- return $fetch<Record<string, any>>(`/api/members/app/${app}`, {
61
+ return useNuxtApp().$api<Record<string, any>>(`/api/members/app/${app}`, {
62
62
  method: "GET",
63
63
  query: { page, limit, search, user, org, status },
64
64
  });
@@ -67,19 +67,25 @@ export default function useMember() {
67
67
  verificationId: string,
68
68
  payload: Record<string, any>
69
69
  ) {
70
- return $fetch<Record<string, any>>(`/api/users/invite/${verificationId}`, {
71
- method: "POST",
72
- body: payload,
73
- });
70
+ return useNuxtApp().$api<Record<string, any>>(
71
+ `/api/users/invite/${verificationId}`,
72
+ {
73
+ method: "POST",
74
+ body: payload,
75
+ }
76
+ );
74
77
  }
75
78
 
76
79
  function createMemberInvite(verificatonId: string) {
77
- return $fetch<TMember>(`/api/members/verification/${verificatonId}`, {
78
- method: "POST",
79
- });
80
+ return useNuxtApp().$api<TMember>(
81
+ `/api/members/verification/${verificatonId}`,
82
+ {
83
+ method: "POST",
84
+ }
85
+ );
80
86
  }
81
87
  function updateMemberStatus(id: string, status: string) {
82
- return $fetch<Record<string, any>>(
88
+ return useNuxtApp().$api<Record<string, any>>(
83
89
  `/api/members/status/${status}/id/${id}`,
84
90
  {
85
91
  method: "PUT",
@@ -88,21 +94,27 @@ export default function useMember() {
88
94
  }
89
95
 
90
96
  function updateRoleById(id: string, role: string) {
91
- return $fetch<Record<string, any>>(`/api/members/role/id/${id}`, {
92
- method: "PATCH",
93
- body: { role },
94
- });
97
+ return useNuxtApp().$api<Record<string, any>>(
98
+ `/api/members/role/id/${id}`,
99
+ {
100
+ method: "PATCH",
101
+ body: { role },
102
+ }
103
+ );
95
104
  }
96
105
 
97
106
  function updateStatusById(id: string, status: string) {
98
- return $fetch<Record<string, any>>(`/api/members/status/id/${id}`, {
99
- method: "PATCH",
100
- body: { status },
101
- });
107
+ return useNuxtApp().$api<Record<string, any>>(
108
+ `/api/members/status/id/${id}`,
109
+ {
110
+ method: "PATCH",
111
+ body: { status },
112
+ }
113
+ );
102
114
  }
103
115
 
104
116
  function deleteById(id: string) {
105
- return $fetch<Record<string, any>>(`/api/members/id/${id}`, {
117
+ return useNuxtApp().$api<Record<string, any>>(`/api/members/id/${id}`, {
106
118
  method: "DELETE",
107
119
  });
108
120
  }
@@ -5,7 +5,7 @@ export default function useOrder() {
5
5
  page = 1,
6
6
  status = "succeeded",
7
7
  } = {}) {
8
- return $fetch<Record<string, any>>("/api/orders", {
8
+ return useNuxtApp().$api<Record<string, any>>("/api/orders", {
9
9
  method: "GET",
10
10
  query: {
11
11
  search,
@@ -4,14 +4,14 @@ export default function useOrg() {
4
4
  seats: number;
5
5
  }
6
6
  ) {
7
- return $fetch<Record<string, any>>("/api/organizations", {
7
+ return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
8
8
  method: "POST",
9
9
  body: value,
10
10
  });
11
11
  }
12
12
 
13
13
  function getAll({ page = 1, search = "", limit = 20, status = "" } = {}) {
14
- return $fetch<Record<string, any>>("/api/organizations", {
14
+ return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
15
15
  method: "GET",
16
16
  query: {
17
17
  page,
@@ -23,27 +23,33 @@ export default function useOrg() {
23
23
  }
24
24
 
25
25
  function getById(id = "") {
26
- return $fetch<Record<string, any>>(`/api/organizations/id/${id}`, {
27
- method: "GET",
28
- });
26
+ return useNuxtApp().$api<Record<string, any>>(
27
+ `/api/organizations/id/${id}`,
28
+ {
29
+ method: "GET",
30
+ }
31
+ );
29
32
  }
30
33
 
31
34
  function getByUserId({ page = 1, search = "", user = "", limit = 20 } = {}) {
32
- return $fetch<Record<string, any>>(`/api/organizations/user/${user}`, {
33
- method: "GET",
34
- query: {
35
- page,
36
- search,
37
- limit,
38
- },
39
- });
35
+ return useNuxtApp().$api<Record<string, any>>(
36
+ `/api/organizations/user/${user}`,
37
+ {
38
+ method: "GET",
39
+ query: {
40
+ page,
41
+ search,
42
+ limit,
43
+ },
44
+ }
45
+ );
40
46
  }
41
47
 
42
48
  function updateById(
43
49
  id: string,
44
50
  options: Pick<TOrg, "name" | "description" | "email" | "contact">
45
51
  ) {
46
- return $fetch(`/api/organizations/id/${id}`, {
52
+ return useNuxtApp().$api(`/api/organizations/id/${id}`, {
47
53
  method: "PATCH",
48
54
  body: options,
49
55
  });
@@ -9,17 +9,20 @@ export default function usePaymentMethod() {
9
9
  cancel_return_url = "",
10
10
  category = "individual",
11
11
  } = {}) {
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
- });
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
+ );
23
26
  }
24
27
 
25
28
  function linkCard({
@@ -34,7 +37,7 @@ export default function usePaymentMethod() {
34
37
  failure_return_url = "",
35
38
  subscriptionData = {},
36
39
  } = {}) {
37
- return $fetch<Record<string, any>>("/api/payment-methods/card", {
40
+ return useNuxtApp().$api<Record<string, any>>("/api/payment-methods/card", {
38
41
  method: "POST",
39
42
  body: {
40
43
  cardType,
@@ -52,7 +55,7 @@ export default function usePaymentMethod() {
52
55
  }
53
56
 
54
57
  function getByUser(user = "") {
55
- return $fetch<Array<Record<string, any>>>(
58
+ return useNuxtApp().$api<Array<Record<string, any>>>(
56
59
  `/api/payment-methods/user/${user}`,
57
60
  {
58
61
  method: "GET",
@@ -61,7 +64,7 @@ export default function usePaymentMethod() {
61
64
  }
62
65
 
63
66
  function getByOrg(org = "") {
64
- return $fetch<Array<Record<string, any>>>(
67
+ return useNuxtApp().$api<Array<Record<string, any>>>(
65
68
  `/api/payment-methods/org/${org}`,
66
69
  {
67
70
  method: "GET",
@@ -70,11 +73,15 @@ export default function usePaymentMethod() {
70
73
  }
71
74
 
72
75
  function getById(id = "") {
73
- return $fetch<Record<string, any>>(`/api/payment-methods/id/${id}`);
76
+ return useNuxtApp().$api<Record<string, any>>(
77
+ `/api/payment-methods/id/${id}`
78
+ );
74
79
  }
75
80
 
76
81
  function getByCustomerId(id = "") {
77
- return $fetch<Record<string, any>>(`/api/payment-methods/customer/${id}`);
82
+ return useNuxtApp().$api<Record<string, any>>(
83
+ `/api/payment-methods/customer/${id}`
84
+ );
78
85
  }
79
86
 
80
87
  const eWalletNumber = useState("eWalletNumber", () => "");
@@ -87,10 +94,13 @@ export default function usePaymentMethod() {
87
94
  const selectedPaymentMethod = useState("selectedPaymentMethod", () => "");
88
95
 
89
96
  function linkOnly(value: Record<string, any>) {
90
- return $fetch<Record<string, any>>("/api/payment-methods/link-only", {
91
- method: "POST",
92
- body: value,
93
- });
97
+ return useNuxtApp().$api<Record<string, any>>(
98
+ "/api/payment-methods/link-only",
99
+ {
100
+ method: "POST",
101
+ body: value,
102
+ }
103
+ );
94
104
  }
95
105
 
96
106
  const supportedEwallets = [
@@ -298,10 +308,13 @@ export default function usePaymentMethod() {
298
308
  }
299
309
 
300
310
  function updateStatusById(id: string, status: string) {
301
- return $fetch<Record<string, any>>(`/api/payment-methods/status/${id}`, {
302
- method: "PATCH",
303
- body: { status },
304
- });
311
+ return useNuxtApp().$api<Record<string, any>>(
312
+ `/api/payment-methods/status/${id}`,
313
+ {
314
+ method: "PATCH",
315
+ body: { status },
316
+ }
317
+ );
305
318
  }
306
319
 
307
320
  return {
@@ -56,7 +56,7 @@ export default function usePermission() {
56
56
  });
57
57
 
58
58
  function addPerm(value: TPerm) {
59
- return $fetch("/api/permissions", {
59
+ return useNuxtApp().$api("/api/permissions", {
60
60
  method: "POST",
61
61
  body: value,
62
62
  });
@@ -66,7 +66,7 @@ export default function usePermission() {
66
66
  id: string,
67
67
  value: Pick<TPerm, "key" | "name" | "group" | "description">
68
68
  ) {
69
- return $fetch(`/api/permissions/id/${id}`, {
69
+ return useNuxtApp().$api(`/api/permissions/id/${id}`, {
70
70
  method: "PATCH",
71
71
  body: value,
72
72
  });
@@ -79,14 +79,14 @@ export default function usePermission() {
79
79
  app = "",
80
80
  status = "active",
81
81
  } = {}) {
82
- return $fetch<Record<string, any>>("/api/permissions", {
82
+ return useNuxtApp().$api<Record<string, any>>("/api/permissions", {
83
83
  method: "GET",
84
84
  query: { page, limit, search, app, status },
85
85
  });
86
86
  }
87
87
 
88
88
  function deletePermById(id: string) {
89
- return $fetch(`/api/permissions/id/${id}`, {
89
+ return useNuxtApp().$api(`/api/permissions/id/${id}`, {
90
90
  method: "DELETE",
91
91
  });
92
92
  }
@@ -99,7 +99,7 @@ export default function usePermission() {
99
99
  });
100
100
 
101
101
  function addPermGroup(value: Pick<TPermGroup, "app" | "key" | "label">) {
102
- return $fetch("/api/permissions/groups", {
102
+ return useNuxtApp().$api("/api/permissions/groups", {
103
103
  method: "POST",
104
104
  body: value,
105
105
  });
@@ -109,7 +109,7 @@ export default function usePermission() {
109
109
  id: string,
110
110
  value: Pick<TPermGroup, "key" | "label">
111
111
  ) {
112
- return $fetch(`/api/permissions/groups/id/${id}`, {
112
+ return useNuxtApp().$api(`/api/permissions/groups/id/${id}`, {
113
113
  method: "PATCH",
114
114
  body: value,
115
115
  });
@@ -122,14 +122,14 @@ export default function usePermission() {
122
122
  app = "",
123
123
  status = "active",
124
124
  } = {}) {
125
- return $fetch<Record<string, any>>("/api/permissions/groups", {
125
+ return useNuxtApp().$api<Record<string, any>>("/api/permissions/groups", {
126
126
  method: "GET",
127
127
  query: { page, limit, search, app, status },
128
128
  });
129
129
  }
130
130
 
131
131
  function deletePermGroupById(id: string) {
132
- return $fetch(`/api/permissions/groups/id/${id}`, {
132
+ return useNuxtApp().$api(`/api/permissions/groups/id/${id}`, {
133
133
  method: "DELETE",
134
134
  });
135
135
  }
@@ -7,7 +7,7 @@ export function usePlan() {
7
7
  });
8
8
 
9
9
  function getDefaultPlan() {
10
- return $fetch<Record<string, any>>(`/api/plans/default`, {
10
+ return useNuxtApp().$api<Record<string, any>>(`/api/plans/default`, {
11
11
  method: "GET",
12
12
  });
13
13
  }
@@ -1,6 +1,6 @@
1
1
  export default function usePrice() {
2
2
  function getByNameType(name: string, type: string) {
3
- return $fetch<Record<string, any>>("/api/prices/price", {
3
+ return useNuxtApp().$api<Record<string, any>>("/api/prices/price", {
4
4
  method: "GET",
5
5
  params: {
6
6
  name,
@@ -15,7 +15,7 @@ export default function usePromo() {
15
15
  });
16
16
 
17
17
  function add(value: TPromo) {
18
- return $fetch<Record<string, any>>("/api/promos", {
18
+ return useNuxtApp().$api<Record<string, any>>("/api/promos", {
19
19
  method: "POST",
20
20
  body: value,
21
21
  });
@@ -27,20 +27,20 @@ export default function usePromo() {
27
27
  search = "",
28
28
  status = "",
29
29
  } = {}) {
30
- return $fetch<Record<string, any>>("/api/promos", {
30
+ return useNuxtApp().$api<Record<string, any>>("/api/promos", {
31
31
  method: "GET",
32
32
  query: { page, limit, search, status },
33
33
  });
34
34
  }
35
35
 
36
36
  async function getByCode(code: string) {
37
- return $fetch<Record<string, any>>(`/api/promos/code/${code}`, {
37
+ return useNuxtApp().$api<Record<string, any>>(`/api/promos/code/${code}`, {
38
38
  method: "GET",
39
39
  });
40
40
  }
41
41
 
42
42
  async function getById(id: string) {
43
- return $fetch<Record<string, any>>(`/api/promos/id/${id}`, {
43
+ return useNuxtApp().$api<Record<string, any>>(`/api/promos/id/${id}`, {
44
44
  method: "GET",
45
45
  });
46
46
  }
@@ -62,14 +62,14 @@ export default function usePromo() {
62
62
  | "usage"
63
63
  >
64
64
  ) {
65
- return $fetch<Record<string, any>>(`/api/promos/id/${id}`, {
65
+ return useNuxtApp().$api<Record<string, any>>(`/api/promos/id/${id}`, {
66
66
  method: "PATCH",
67
67
  body: value,
68
68
  });
69
69
  }
70
70
 
71
71
  async function deleteById(id: string) {
72
- return $fetch<Record<string, any>>(`/api/promos/${id}`, {
72
+ return useNuxtApp().$api<Record<string, any>>(`/api/promos/${id}`, {
73
73
  method: "DELETE",
74
74
  });
75
75
  }
@@ -1,13 +1,13 @@
1
1
  export default function usePromoCode() {
2
2
  function add(value: TPromoCode) {
3
- return $fetch<Record<string, any>>("/api/promo-codes", {
3
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/promo-codes", {
10
+ return useNuxtApp().$api<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 $fetch<TPromoCode>("/api/promo-codes/code", {
21
+ return useNuxtApp().$api<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 $fetch<TPromoCode>(`/api/promo-codes/id/${id}`, {
32
+ return useNuxtApp().$api<TPromoCode>(`/api/promo-codes/id/${id}`, {
33
33
  method: "GET",
34
34
  });
35
35
  }
@@ -2,7 +2,7 @@ export default function useRole() {
2
2
  function add(
3
3
  value: Pick<TRole, "name" | "permissions" | "app" | "org" | "createdBy">
4
4
  ) {
5
- return $fetch("/api/roles", {
5
+ return useNuxtApp().$api("/api/roles", {
6
6
  method: "POST",
7
7
  body: value,
8
8
  });
@@ -15,41 +15,41 @@ export default function useRole() {
15
15
  app = "",
16
16
  org = "",
17
17
  } = {}) {
18
- return $fetch<Record<string, any>>("/api/roles", {
18
+ return useNuxtApp().$api<Record<string, any>>("/api/roles", {
19
19
  method: "GET",
20
20
  query: { search, page, limit, app, org },
21
21
  });
22
22
  }
23
23
 
24
24
  function getById(id: string) {
25
- return $fetch<Record<string, any>>(`/api/roles/id/${id}`, {
25
+ return useNuxtApp().$api<Record<string, any>>(`/api/roles/id/${id}`, {
26
26
  method: "GET",
27
27
  });
28
28
  }
29
29
 
30
30
  function updateById(id: string, value: Pick<TRole, "name" | "permissions">) {
31
- return $fetch(`/api/roles/id/${id}`, {
31
+ return useNuxtApp().$api(`/api/roles/id/${id}`, {
32
32
  method: "PATCH",
33
33
  body: value,
34
34
  });
35
35
  }
36
36
 
37
37
  function updatePermissionById(_id: string, permissions?: Array<string>) {
38
- return $fetch(`/api/roles/permissions/id/${_id}`, {
38
+ return useNuxtApp().$api(`/api/roles/permissions/id/${_id}`, {
39
39
  method: "PATCH",
40
40
  body: { permissions },
41
41
  });
42
42
  }
43
43
 
44
44
  function updateRoleFieldById(_id: string, field: string, value: string) {
45
- return $fetch(`/api/roles/${_id}`, {
45
+ return useNuxtApp().$api(`/api/roles/${_id}`, {
46
46
  method: "PATCH",
47
47
  body: { field, value },
48
48
  });
49
49
  }
50
50
 
51
51
  function deleteById(_id: string) {
52
- return $fetch<Record<string, any>>(`/api/roles/${_id}`, {
52
+ return useNuxtApp().$api<Record<string, any>>(`/api/roles/${_id}`, {
53
53
  method: "DELETE",
54
54
  });
55
55
  }
@@ -10,16 +10,19 @@ export default function useSubscription() {
10
10
  });
11
11
 
12
12
  function getByOrg(org = "") {
13
- return $fetch<Record<string, any>>(`/api/subscriptions/org/${org}`, {
14
- method: "GET",
15
- });
13
+ return useNuxtApp().$api<Record<string, any>>(
14
+ `/api/subscriptions/org/${org}`,
15
+ {
16
+ method: "GET",
17
+ }
18
+ );
16
19
  }
17
20
 
18
21
  function getTransactionsById(
19
22
  id = "",
20
23
  options: { page?: number; limit?: number } = {}
21
24
  ) {
22
- return $fetch<Record<string, any>>(
25
+ return useNuxtApp().$api<Record<string, any>>(
23
26
  `/api/subscriptions/id/${id}/transactions`,
24
27
  {
25
28
  method: "GET",
@@ -32,18 +35,21 @@ export default function useSubscription() {
32
35
  }
33
36
 
34
37
  function updateSeatById({ id = "", seats = 0, amount = 0, user = "" } = {}) {
35
- return $fetch<Record<string, any>>(`/api/subscriptions/id/${id}/seats`, {
36
- method: "PATCH",
37
- body: {
38
- seats,
39
- amount,
40
- user,
41
- },
42
- });
38
+ return useNuxtApp().$api<Record<string, any>>(
39
+ `/api/subscriptions/id/${id}/seats`,
40
+ {
41
+ method: "PATCH",
42
+ body: {
43
+ seats,
44
+ amount,
45
+ user,
46
+ },
47
+ }
48
+ );
43
49
  }
44
50
 
45
51
  function getAll({ page = 1, limit = 20, search = "", status = "" } = {}) {
46
- return $fetch<Record<string, any>>(`/api/subscriptions`, {
52
+ return useNuxtApp().$api<Record<string, any>>(`/api/subscriptions`, {
47
53
  method: "GET",
48
54
  query: {
49
55
  page,
@@ -7,49 +7,49 @@ export default function useUser() {
7
7
  org = "",
8
8
  orgName = "",
9
9
  } = {}) {
10
- return $fetch<Record<string, any>>("/api/auth/invite", {
10
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users/name", {
17
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users/birthday", {
24
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users/gender", {
31
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users/email", {
38
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users/contact", {
45
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>(`/api/users/field/${id}`, {
52
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>("/api/users", {
64
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>(`/api/users/id/${id}`, {
71
+ return useNuxtApp().$api<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 $fetch<Record<string, any>>(`/api/users/invite/${id}`, {
84
+ return useNuxtApp().$api<Record<string, any>>(`/api/users/invite/${id}`, {
85
85
  method: "POST",
86
86
  body: { firstName, lastName, password, referralCode, type },
87
87
  });
@@ -92,7 +92,7 @@ export default function useUser() {
92
92
  newPassword: string;
93
93
  confirmPassword: string;
94
94
  }) {
95
- return $fetch("/api/users/password", {
95
+ return useNuxtApp().$api("/api/users/password", {
96
96
  method: "PATCH",
97
97
  body: value,
98
98
  });
@@ -140,7 +140,7 @@ export default function useUtils() {
140
140
 
141
141
  async function getCountries() {
142
142
  try {
143
- const countries = await $fetch<Array<Record<string, any>>>(
143
+ const countries = await useNuxtApp().$api<Array<Record<string, any>>>(
144
144
  "https://restcountries.com/v3.1/all?fields=name,currencies,idd",
145
145
  { method: "GET" }
146
146
  );
@@ -8,7 +8,7 @@ export default function useUser() {
8
8
  app = "",
9
9
  org = "",
10
10
  } = {}) {
11
- return $fetch<Record<string, any>>("/api/verifications", {
11
+ return useNuxtApp().$api<Record<string, any>>("/api/verifications", {
12
12
  method: "GET",
13
13
  query: { status, search, page, type, email, app, org },
14
14
  });
@@ -20,23 +20,29 @@ export default function useUser() {
20
20
  org: string;
21
21
  role: string;
22
22
  }) {
23
- return $fetch<Record<string, any>>("/api/verifications/member", {
23
+ return useNuxtApp().$api<Record<string, any>>("/api/verifications/member", {
24
24
  method: "POST",
25
25
  body: value,
26
26
  });
27
27
  }
28
28
 
29
29
  function signUp(email: string) {
30
- return $fetch<Record<string, any>>("/api/verifications/sign-up", {
31
- method: "POST",
32
- body: { email },
33
- });
30
+ return useNuxtApp().$api<Record<string, any>>(
31
+ "/api/verifications/sign-up",
32
+ {
33
+ method: "POST",
34
+ body: { email },
35
+ }
36
+ );
34
37
  }
35
38
 
36
39
  function cancelInvite(id: string) {
37
- return $fetch<Record<string, any>>(`/api/verifications/invite/id/${id}`, {
38
- method: "DELETE",
39
- });
40
+ return useNuxtApp().$api<Record<string, any>>(
41
+ `/api/verifications/invite/id/${id}`,
42
+ {
43
+ method: "DELETE",
44
+ }
45
+ );
40
46
  }
41
47
 
42
48
  function orgSetupFee(
@@ -44,10 +50,13 @@ export default function useUser() {
44
50
  seats: number;
45
51
  }
46
52
  ) {
47
- return $fetch<Record<string, any>>("/api/verifications/org-setup-fee", {
48
- method: "POST",
49
- body: value,
50
- });
53
+ return useNuxtApp().$api<Record<string, any>>(
54
+ "/api/verifications/org-setup-fee",
55
+ {
56
+ method: "POST",
57
+ body: value,
58
+ }
59
+ );
51
60
  }
52
61
 
53
62
  return {
package/nuxt.config.ts CHANGED
@@ -15,6 +15,7 @@ export default defineNuxtConfig({
15
15
  secure: true,
16
16
  maxAge: 30 * 24 * 60 * 60,
17
17
  },
18
+ API_CORE: (process.env.API_CORE as string) ?? "http://localhost:5001",
18
19
  APP: (process.env.APP as string) ?? "app",
19
20
  APP_NAME: (process.env.APP_NAME as string) ?? "App",
20
21
  APP_NAME_ROUTE: (process.env.APP_NAME_ROUTE as string) ?? "index",
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.5.0",
5
+ "version": "1.5.1",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
package/plugins/API.ts CHANGED
@@ -1,58 +1,18 @@
1
- import { useFetch } from "nuxt/app";
2
- type useFetchType = typeof useFetch;
3
-
4
1
  export default defineNuxtPlugin(() => {
5
- const { cookieConfig, BASE_URL } = useRuntimeConfig().public;
2
+ const { cookieConfig } = useRuntimeConfig().public;
6
3
 
7
4
  const api = $fetch.create({
8
- baseURL: "/",
9
- retry: 1,
10
- retryStatusCodes: [401],
11
- retryDelay: 500,
12
- onRequest({ options }) {
13
- const accessToken = useCookie("accessToken", cookieConfig).value;
14
- options.headers.set("Authorization", `Bearer ${accessToken}`);
15
- },
16
-
17
- async onResponseError({ response }) {
18
- if (response.status === 401) {
19
- await $fetch("/api/auth/refresh", {
20
- method: "POST",
21
- body: JSON.stringify({
22
- token: useCookie("refreshToken", cookieConfig).value,
23
- }),
24
-
25
- onResponse({ response }) {
26
- if (response.status === 200) {
27
- useCookie("accessToken", cookieConfig).value =
28
- response._data.token;
29
- }
30
- },
31
- });
32
- }
5
+ baseURL: useRuntimeConfig().public.API_CORE,
6
+ credentials: "include",
7
+ headers: {
8
+ cookie: `domain=${cookieConfig.domain}; Max-Age=${cookieConfig.maxAge}; Secure=${cookieConfig.secure}`,
33
9
  },
34
10
  });
35
11
 
36
- const useAPI: useFetchType = (path, options = {}) => {
37
- options.lazy = true;
38
- options.retry = 1;
39
- options.retryStatusCodes = [401];
40
- options.retryDelay = 500;
41
- options.baseURL = (BASE_URL as string) ?? "/";
42
-
43
- options.headers = {
44
- ...options.headers,
45
- Authorization: `Bearer ${useCookie("accessToken", cookieConfig).value}`,
46
- };
47
-
48
- return useFetch(path, options);
49
- };
50
-
51
- // Expose to $fetch
12
+ // Expose to useNuxtApp().$api
52
13
  return {
53
14
  provide: {
54
15
  api,
55
- useAPI,
56
16
  },
57
17
  };
58
18
  });
@@ -14,7 +14,9 @@ export default defineNuxtPlugin(() => {
14
14
  }
15
15
 
16
16
  try {
17
- currentUser.value = await $fetch<TUser>(`/api/users/id/${user}`);
17
+ currentUser.value = await useNuxtApp().$api<TUser>(
18
+ `/api/users/id/${user}`
19
+ );
18
20
  } catch (error) {
19
21
  navigateTo({ name: "index" });
20
22
  }
@@ -33,6 +33,10 @@ export default defineNuxtPlugin((app) => {
33
33
  variant: "outlined",
34
34
  density: "comfortable",
35
35
  },
36
+ VCombobox: {
37
+ variant: "outlined",
38
+ density: "comfortable",
39
+ },
36
40
  },
37
41
  theme: {
38
42
  defaultTheme: "defaultTheme",
@@ -0,0 +1,18 @@
1
+ declare type TJobPost = {
2
+ _id?: ObjectId;
3
+ org: ObjectId;
4
+ orgName?: string;
5
+ title: string;
6
+ setup: string;
7
+ location: string;
8
+ type: string;
9
+ minSalary?: number;
10
+ maxSalary?: number;
11
+ currency?: string;
12
+ payPeriod?: string;
13
+ description: string;
14
+ status?: string;
15
+ createdAt?: Date;
16
+ updatedAt?: Date;
17
+ deletedAt?: Date;
18
+ };