@goweekdays/layer-common 1.1.0 → 1.1.2

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,17 @@
1
1
  # @goweekdays/layer-common
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a76e4a: Invitation management - fix form component
8
+
9
+ ## 1.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 294db8a: useAuth - remove unused codes
14
+
3
15
  ## 1.1.0
4
16
 
5
17
  ### Minor Changes
@@ -47,16 +47,20 @@
47
47
  <v-tabs>
48
48
  <v-tab
49
49
  :to="{
50
- name: 'org-organization-invitations-status-status',
51
- params: { status: 'pending', organization },
50
+ name: props.route,
51
+ params: props.org
52
+ ? { status: 'pending', org: props.org }
53
+ : { status: 'active' },
52
54
  }"
53
55
  >
54
56
  Pending
55
57
  </v-tab>
56
58
  <v-tab
57
59
  :to="{
58
- name: 'org-organization-invitations-status-status',
59
- params: { status: 'expired', organization },
60
+ name: props.route,
61
+ params: props.org
62
+ ? { status: 'expired', org: props.org }
63
+ : { status: 'pending' },
60
64
  }"
61
65
  >
62
66
  Expired
@@ -91,6 +95,10 @@
91
95
 
92
96
  <script setup lang="ts">
93
97
  const props = defineProps({
98
+ org: {
99
+ type: String,
100
+ default: "",
101
+ },
94
102
  status: {
95
103
  type: String,
96
104
  default: "active",
@@ -110,6 +118,10 @@ const props = defineProps({
110
118
  params: {},
111
119
  }),
112
120
  },
121
+ route: {
122
+ type: String,
123
+ default: "index",
124
+ },
113
125
  });
114
126
 
115
127
  const organization = (useRoute().params.organization as string) ?? "";
@@ -8,14 +8,6 @@ export default function useLocalAuth() {
8
8
  return;
9
9
  }
10
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
11
  const user = useCookie("user", cookieConfig).value;
20
12
 
21
13
  const { data: getCurrentUserReq, error: getCurrentUserErr } =
@@ -44,38 +36,10 @@ export default function useLocalAuth() {
44
36
  });
45
37
  }
46
38
 
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
39
  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
- }
40
+ useCookie("sid", cookieConfig).value = null;
41
+ useCookie("user", cookieConfig).value = null;
42
+ useCookie("role", cookieConfig).value = null;
79
43
  }
80
44
 
81
45
  async function getCurrentUser() {
@@ -145,9 +109,7 @@ export default function useLocalAuth() {
145
109
  authenticate,
146
110
  login,
147
111
  logout,
148
- clearCookies,
149
112
  getCurrentUser,
150
- setToken,
151
113
  forgotPassword,
152
114
  resetPassword,
153
115
  currentUser,
@@ -3,7 +3,7 @@ export default function useUtils() {
3
3
 
4
4
  const emailRule = (v: string): true | string => {
5
5
  const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
6
- if(!v) return true;
6
+ if (!v) return true;
7
7
  return regex.test(v) || "Please enter a valid email address";
8
8
  };
9
9
 
@@ -266,6 +266,10 @@ export default function useUtils() {
266
266
  return params;
267
267
  }
268
268
 
269
+ function positiveNumberRule(v: number) {
270
+ return (v && v >= 1) || "Value must be greater or equal to 1";
271
+ }
272
+
269
273
  return {
270
274
  requiredRule,
271
275
  emailRule,
@@ -291,5 +295,6 @@ export default function useUtils() {
291
295
  getRouteParam,
292
296
  replaceMatch,
293
297
  setRouteParams,
298
+ positiveNumberRule,
294
299
  };
295
300
  }
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.1.0",
5
+ "version": "1.1.2",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"