@goweekdays/layer-common 1.4.6 → 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.
@@ -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",
@@ -69,8 +70,8 @@ export default defineNuxtConfig({
69
70
  "/api/entities/**": { proxy: `${process.env.API_CORE}/api/entities/**` },
70
71
  "/api/workflows/**": { proxy: `${process.env.API_CORE}/api/workflows/**` },
71
72
  "/api/roles/**": { proxy: `${process.env.API_CORE}/api/roles/**` },
72
- "/api/promo-codes/**": {
73
- proxy: `${process.env.API_CORE}/api/promo-codes/**`,
73
+ "/api/promos/**": {
74
+ proxy: `${process.env.API_CORE}/api/promos/**`,
74
75
  },
75
76
  "/api/verifications/**": {
76
77
  proxy: `${process.env.API_CORE}/api/verifications/**`,
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.4.6",
5
+ "version": "1.5.1",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -21,7 +21,7 @@
21
21
  rounded
22
22
  @click="navigateTo({ name: 'index' })"
23
23
  >
24
- Return to Landing Page
24
+ Return
25
25
  </v-btn>
26
26
  </v-row>
27
27
  </v-col>
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
+ };
package/types/org.d.ts CHANGED
@@ -5,6 +5,7 @@ declare type TOrg = {
5
5
  email?: string;
6
6
  contact?: string;
7
7
  createdBy: string;
8
+ promoCode?: string;
8
9
  status?: string;
9
10
  createdAt?: string;
10
11
  updatedAt?: string;
@@ -0,0 +1,22 @@
1
+ declare type TPromo = {
2
+ _id?: string;
3
+ code: string;
4
+ type: "flat" | "fixed" | "volume";
5
+ flatRate?: number; // regardless of seats
6
+ fixedRate?: number; // per seat
7
+ tiers?: Array<{
8
+ minSeats: number;
9
+ maxSeats: number;
10
+ rate: number;
11
+ }>;
12
+ currency: string;
13
+ startDate?: Date | string;
14
+ endDate?: Date | string;
15
+ seats?: number;
16
+ usage?: number;
17
+ apps?: string[];
18
+ status?: "active" | "inactive" | "expired";
19
+ createdAt?: Date | string;
20
+ updatedAt?: Date | string;
21
+ deletedAt?: Date | string;
22
+ };