@eeplatform/nuxt-layer-common 1.2.1 → 1.2.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 +6 -0
- package/composables/useLocal.ts +3 -3
- package/composables/useLocalAuth.ts +12 -14
- package/composables/useLocalSetup.ts +5 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/composables/useLocal.ts
CHANGED
|
@@ -30,19 +30,19 @@ export default function useLocal() {
|
|
|
30
30
|
title: "School",
|
|
31
31
|
icon: "ph:building-bold",
|
|
32
32
|
link: APP_SCHOOL as string,
|
|
33
|
-
landingPage: "
|
|
33
|
+
landingPage: "",
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
title: "Division",
|
|
37
37
|
icon: "ph:building-apartment-bold",
|
|
38
38
|
link: APP_DIVISION as string,
|
|
39
|
-
landingPage: "
|
|
39
|
+
landingPage: "",
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
title: "Region",
|
|
43
43
|
icon: "ph:buildings-bold",
|
|
44
44
|
link: APP_REGION as string,
|
|
45
|
-
landingPage: "
|
|
45
|
+
landingPage: "",
|
|
46
46
|
},
|
|
47
47
|
];
|
|
48
48
|
});
|
|
@@ -38,7 +38,7 @@ export default function useLocalAuth() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async function login({ email = "", password = "", role = "" }) {
|
|
41
|
-
return useNuxtApp().$api<
|
|
41
|
+
return useNuxtApp().$api<Record<string, any>>("/api/auth/login", {
|
|
42
42
|
method: "POST",
|
|
43
43
|
body: JSON.stringify({ email, password, role }),
|
|
44
44
|
});
|
|
@@ -78,19 +78,17 @@ export default function useLocalAuth() {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
function getCurrentUser() {
|
|
82
82
|
const user = useCookie("user", cookieConfig).value;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
method: "GET",
|
|
87
|
-
});
|
|
83
|
+
const { data: userData } = useLazyAsyncData("get-current-user", () =>
|
|
84
|
+
useNuxtApp().$api<TUser>(`/api/users/id/${user}`)
|
|
85
|
+
);
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
87
|
+
watchEffect(() => {
|
|
88
|
+
if (userData.value) {
|
|
89
|
+
currentUser.value = userData.value;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
async function forgotPassword(email: string) {
|
|
@@ -129,13 +127,13 @@ export default function useLocalAuth() {
|
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
function verify(id: string) {
|
|
132
|
-
return useNuxtApp().$api<
|
|
130
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/auth/verify/${id}`, {
|
|
133
131
|
method: "GET",
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
function signUp(email: string, referral: string) {
|
|
138
|
-
return useNuxtApp().$api<
|
|
136
|
+
return useNuxtApp().$api<Record<string, any>>("/api/auth/sign-up", {
|
|
139
137
|
method: "POST",
|
|
140
138
|
body: { email, referral },
|
|
141
139
|
});
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export function useLocalSetup(type: string, org?: string) {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const userId = computed(() => currentUser.value?._id ?? "");
|
|
2
|
+
const userId = computed(() => useCookie("user").value ?? "");
|
|
5
3
|
|
|
6
4
|
const { getByUserType } = useMember();
|
|
7
5
|
|
|
8
6
|
const { data: userMemberData, error: userMemberError } = useLazyAsyncData(
|
|
9
7
|
"get-member-by-id",
|
|
10
8
|
() => getByUserType(userId.value, type, org),
|
|
11
|
-
{ watch: [userId]
|
|
9
|
+
{ watch: [userId] }
|
|
12
10
|
);
|
|
13
11
|
|
|
14
12
|
watchEffect(() => {
|
|
@@ -40,7 +38,10 @@ export function useLocalSetup(type: string, org?: string) {
|
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
|
|
41
|
+
const id = computed(() => userMemberData.value?.org ?? "id");
|
|
42
|
+
|
|
43
43
|
return {
|
|
44
44
|
userAppRole,
|
|
45
|
+
id,
|
|
45
46
|
};
|
|
46
47
|
}
|