@7365admin1/layer-common 3.2.1-staging.71 → 3.2.1-staging.73
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.
|
@@ -721,9 +721,9 @@ const {
|
|
|
721
721
|
_getFeedbacks({
|
|
722
722
|
page: page.value,
|
|
723
723
|
site: route.params.site as string,
|
|
724
|
-
provider: currentUser.value
|
|
725
|
-
...(currentUser.value
|
|
726
|
-
userId: currentUser.value
|
|
724
|
+
provider: currentUser.value?.serviceProvider,
|
|
725
|
+
...(currentUser.value?.type != "site" && {
|
|
726
|
+
userId: currentUser.value?._id,
|
|
727
727
|
}),
|
|
728
728
|
service: "Security",
|
|
729
729
|
dateFrom: moment(startDate.value, "DD/MM/YYYY").startOf("day"),
|
|
@@ -998,9 +998,9 @@ async function handleAccept() {
|
|
|
998
998
|
_id: feedbackData.value._id,
|
|
999
999
|
statusUpdate: {
|
|
1000
1000
|
status: "In-Progress",
|
|
1001
|
-
updatedById: currentUser.value
|
|
1002
|
-
updatedByName: `${currentUser.value
|
|
1003
|
-
assignee: currentUser.value
|
|
1001
|
+
updatedById: currentUser.value?._id,
|
|
1002
|
+
updatedByName: `${currentUser.value?.givenName} ${currentUser.value?.surname}`,
|
|
1003
|
+
assignee: currentUser.value?._id,
|
|
1004
1004
|
provider: currentUser.value?.serviceProvider,
|
|
1005
1005
|
},
|
|
1006
1006
|
};
|
|
@@ -1158,7 +1158,7 @@ async function submit() {
|
|
|
1158
1158
|
isSubmitting.value = true;
|
|
1159
1159
|
|
|
1160
1160
|
const result = await createFeedback({
|
|
1161
|
-
createdBy: currentUser.value
|
|
1161
|
+
createdBy: currentUser.value?._id,
|
|
1162
1162
|
description: _feedback.value.description,
|
|
1163
1163
|
attachments: _feedback.value.attachments,
|
|
1164
1164
|
site: route.params.site as string,
|
|
@@ -588,7 +588,7 @@
|
|
|
588
588
|
:org="orgId"
|
|
589
589
|
:site="siteId"
|
|
590
590
|
:visitor-data="selectedVisitorDataObject"
|
|
591
|
-
:current-user="currentUser
|
|
591
|
+
:current-user="currentUser?._id"
|
|
592
592
|
:type="activeVisitorFormType"
|
|
593
593
|
:enable-unregistered="enableUnregistered"
|
|
594
594
|
@back="handleClickBack"
|
|
@@ -1707,7 +1707,7 @@ async function handleVisitorDataFromScannedQRCodeCheckInOut(
|
|
|
1707
1707
|
site: visitorData.site ?? siteId,
|
|
1708
1708
|
},
|
|
1709
1709
|
update: {
|
|
1710
|
-
updatedBy: currentUser.value
|
|
1710
|
+
updatedBy: currentUser.value?._id,
|
|
1711
1711
|
visitorPass: visitorPass.find(
|
|
1712
1712
|
(i: Record<string, any>) => i.keyId === null
|
|
1713
1713
|
)
|
|
@@ -89,13 +89,13 @@ export default function useComment() {
|
|
|
89
89
|
|
|
90
90
|
comments.value = _comments.items
|
|
91
91
|
.map((comment: any) => {
|
|
92
|
-
if (comment.createdBy === currentUser.value
|
|
92
|
+
if (comment.createdBy === currentUser.value?._id) {
|
|
93
93
|
comment.justify = "end";
|
|
94
94
|
} else {
|
|
95
95
|
comment.justify = "start";
|
|
96
96
|
if (
|
|
97
97
|
((Array.isArray(comment.seenBy) &&
|
|
98
|
-
!comment.seenBy.includes(currentUser.value
|
|
98
|
+
!comment.seenBy.includes(currentUser.value?._id)) ||
|
|
99
99
|
!comment?.seenBy) &&
|
|
100
100
|
comment?._id
|
|
101
101
|
) {
|
|
@@ -111,7 +111,7 @@ export default function useComment() {
|
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
if (Array.isArray(updateSeenIds) && updateSeenIds.length > 0) {
|
|
114
|
-
const seenBy = await updateSeenBy(updateSeenIds, currentUser.value
|
|
114
|
+
const seenBy = await updateSeenBy(updateSeenIds, currentUser.value?._id);
|
|
115
115
|
}
|
|
116
116
|
} catch (error) {
|
|
117
117
|
console.log("error :", error);
|
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
export default function useLocalAuth() {
|
|
2
2
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
country: "",
|
|
6
|
-
address1: "",
|
|
7
|
-
address2: "",
|
|
8
|
-
city: "",
|
|
9
|
-
province: "",
|
|
10
|
-
postalCode: "",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const user = {
|
|
14
|
-
_id: "",
|
|
15
|
-
givenName: "",
|
|
16
|
-
middleName: "",
|
|
17
|
-
surname: "",
|
|
18
|
-
address: _address,
|
|
19
|
-
email: "",
|
|
20
|
-
password: "",
|
|
21
|
-
type: "",
|
|
22
|
-
createdAt: "",
|
|
23
|
-
organization: "",
|
|
24
|
-
role: "",
|
|
25
|
-
primaryPhone: "",
|
|
26
|
-
mobilePhone: "",
|
|
27
|
-
serviceProviders: [],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const currentUser = useState(
|
|
31
|
-
"currentUser",
|
|
32
|
-
(): TUser | null => JSON.parse(JSON.stringify(user))
|
|
33
|
-
);
|
|
4
|
+
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
34
5
|
|
|
35
6
|
async function authenticate() {
|
|
36
7
|
const user = useCookie("user", cookieConfig).value;
|
|
@@ -41,9 +12,7 @@ export default function useLocalAuth() {
|
|
|
41
12
|
);
|
|
42
13
|
|
|
43
14
|
watchEffect(() => {
|
|
44
|
-
|
|
45
|
-
currentUser.value = getCurrentUserReq.value as TUser;
|
|
46
|
-
}
|
|
15
|
+
currentUser.value = (getCurrentUserReq.value as TUser | null) ?? null;
|
|
47
16
|
});
|
|
48
17
|
|
|
49
18
|
watchEffect(() => {
|
|
@@ -70,6 +39,7 @@ export default function useLocalAuth() {
|
|
|
70
39
|
useCookie("sid", cookieConfig).value = null;
|
|
71
40
|
useCookie("user", cookieConfig).value = null;
|
|
72
41
|
useCookie("organization", cookieConfig).value = null;
|
|
42
|
+
currentUser.value = null;
|
|
73
43
|
}
|
|
74
44
|
|
|
75
45
|
async function logout() {
|
|
@@ -79,17 +49,20 @@ export default function useLocalAuth() {
|
|
|
79
49
|
await useNuxtApp().$api(`/api/auth/${sid}`, {
|
|
80
50
|
method: "DELETE",
|
|
81
51
|
});
|
|
82
|
-
|
|
83
|
-
clearCookies();
|
|
84
52
|
} catch (error) {
|
|
85
53
|
console.error("Logout failed:", error);
|
|
86
54
|
}
|
|
55
|
+
|
|
56
|
+
clearCookies();
|
|
87
57
|
}
|
|
88
58
|
}
|
|
89
59
|
|
|
90
60
|
async function getCurrentUser() {
|
|
91
61
|
const user = useCookie("user", cookieConfig).value;
|
|
92
|
-
if (!user)
|
|
62
|
+
if (!user) {
|
|
63
|
+
currentUser.value = null;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
93
66
|
const _user = await useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
|
|
94
67
|
method: "GET",
|
|
95
68
|
});
|