l-min-components 1.0.828 → 1.0.831
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/package.json
CHANGED
|
@@ -11,6 +11,30 @@ const useHeader = () => {
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const [{ ...retrieveUserDetailsData }, retrieveUserDetails] = useAxios();
|
|
15
|
+
|
|
16
|
+
const handleRetrieveUserDetails = async (data) => {
|
|
17
|
+
await retrieveUserDetails({
|
|
18
|
+
method: "patch",
|
|
19
|
+
url: "/iam/v1/users/me/",
|
|
20
|
+
data: {
|
|
21
|
+
...data,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const [{ ...updateUserAccountData }, updateUserAccount] = useAxios();
|
|
27
|
+
|
|
28
|
+
const handleUpdateUserAccount = async (id, data) => {
|
|
29
|
+
await updateUserAccount({
|
|
30
|
+
method: "patch",
|
|
31
|
+
url: `/iam/v1/accounts/${id}/`,
|
|
32
|
+
data: {
|
|
33
|
+
...data,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
14
38
|
// get user accounts detail
|
|
15
39
|
|
|
16
40
|
const [{ ...userAccountsDetail }, getUserAccountsDetail] = useAxios();
|
|
@@ -216,6 +240,10 @@ const useHeader = () => {
|
|
|
216
240
|
handleGetUserPlan,
|
|
217
241
|
getCurrentSubscriptionData,
|
|
218
242
|
handleCurrentSubscription,
|
|
243
|
+
retrieveUserDetailsData,
|
|
244
|
+
handleRetrieveUserDetails,
|
|
245
|
+
updateUserAccountData,
|
|
246
|
+
handleUpdateUserAccount
|
|
219
247
|
};
|
|
220
248
|
};
|
|
221
249
|
export default useHeader;
|
|
@@ -29,6 +29,7 @@ import usFlag from "../../assets/images/usFlag.png";
|
|
|
29
29
|
import LanguageDropdown from "./languageDropdown";
|
|
30
30
|
import { getCookie } from "./getCookies";
|
|
31
31
|
import { data } from "../GraphMap/data";
|
|
32
|
+
import { languagesData } from "./languages";
|
|
32
33
|
/**
|
|
33
34
|
* @param {{
|
|
34
35
|
* type: string,
|
|
@@ -59,6 +60,10 @@ const HeaderComponent = (props) => {
|
|
|
59
60
|
handleGeneralNotificationCount,
|
|
60
61
|
notificationData,
|
|
61
62
|
handleGetNotification,
|
|
63
|
+
retrieveUserDetailsData,
|
|
64
|
+
handleRetrieveUserDetails,
|
|
65
|
+
updateUserAccountData,
|
|
66
|
+
handleUpdateUserAccount
|
|
62
67
|
} = useHeader();
|
|
63
68
|
const { pathname } = useLocation();
|
|
64
69
|
const {
|
|
@@ -69,6 +74,7 @@ const HeaderComponent = (props) => {
|
|
|
69
74
|
defaultLang,
|
|
70
75
|
isLoading,
|
|
71
76
|
setIsLoading,
|
|
77
|
+
setDefaultLang
|
|
72
78
|
} = useContext(OutletContext);
|
|
73
79
|
const [selectedAccount, setSelectedAccount] = useState();
|
|
74
80
|
const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
|
|
@@ -382,8 +388,17 @@ const HeaderComponent = (props) => {
|
|
|
382
388
|
handleGetUnreadNotification();
|
|
383
389
|
handleGeneralNotificationCount();
|
|
384
390
|
}, [notificationMarkReadData?.response]);
|
|
391
|
+
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
if (generalData?.defaultAccount?.language) {
|
|
394
|
+
setDefaultLang(generalData?.defaultAccount?.language);
|
|
395
|
+
}
|
|
396
|
+
}, [generalData]);
|
|
397
|
+
|
|
398
|
+
|
|
385
399
|
const value = JSON?.parse(localStorage.getItem("defaultLang"));
|
|
386
400
|
const currentFlag = value?.flag;
|
|
401
|
+
const selectedLanguage = languagesData.find((lang) => lang?.slug === defaultLang);
|
|
387
402
|
//console.log("defaultLang", defaultLang);
|
|
388
403
|
|
|
389
404
|
// When Developer and on staging
|
|
@@ -489,7 +504,7 @@ const HeaderComponent = (props) => {
|
|
|
489
504
|
setIsOpen();
|
|
490
505
|
}}
|
|
491
506
|
>
|
|
492
|
-
<img src={currentFlag || usFlag} alt="" />
|
|
507
|
+
<img src={selectedLanguage?.flag || currentFlag || usFlag} alt="" />
|
|
493
508
|
<ArrowDownIcon />
|
|
494
509
|
</div>
|
|
495
510
|
{languageDropdown && (
|
|
@@ -30,6 +30,13 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
|
|
|
30
30
|
isLoading,
|
|
31
31
|
setIsLoading,
|
|
32
32
|
} = useContext(OutletContext);
|
|
33
|
+
const {
|
|
34
|
+
retrieveUserDetailsData,
|
|
35
|
+
handleRetrieveUserDetails,
|
|
36
|
+
updateUserAccountData,
|
|
37
|
+
handleUpdateUserAccount,
|
|
38
|
+
} = useHeader();
|
|
39
|
+
|
|
33
40
|
const languagesData = [
|
|
34
41
|
{
|
|
35
42
|
name: "English",
|
|
@@ -139,10 +146,18 @@ const LanguageDropdown = ({ languageDropdown, setLanguageDropdown }) => {
|
|
|
139
146
|
? setIsLoading(false)
|
|
140
147
|
: setIsLoading(true);
|
|
141
148
|
localStorage.setItem("defaultLang", JSON.stringify(item));
|
|
149
|
+
if (generalData?.defaultAccount?.id) {
|
|
150
|
+
handleUpdateUserAccount(generalData?.defaultAccount?.id, {
|
|
151
|
+
...generalData?.selectedAccount?.metadata,
|
|
152
|
+
language: item?.slug,
|
|
153
|
+
});
|
|
154
|
+
handleRetrieveUserDetails({
|
|
155
|
+
language: item?.slug,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
142
158
|
}}
|
|
143
159
|
>
|
|
144
|
-
<img src={item?.flag} alt="" />{
|
|
145
|
-
<span>{findText(item?.name)}</span>
|
|
160
|
+
<img src={item?.flag} alt="" /> <span>{item?.name}</span>
|
|
146
161
|
</p>
|
|
147
162
|
))}
|
|
148
163
|
</>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import usFlag from "../../assets/images/usFlag.png";
|
|
2
|
+
import koreanFlag from "../../assets/images/koreaFlag.png";
|
|
3
|
+
|
|
4
|
+
export const languagesData = [
|
|
5
|
+
{
|
|
6
|
+
name: "English",
|
|
7
|
+
flag: usFlag,
|
|
8
|
+
slug: "en",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "Korean",
|
|
12
|
+
flag: koreanFlag,
|
|
13
|
+
slug: "ko",
|
|
14
|
+
},
|
|
15
|
+
];
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useState } from "react";
|
|
2
2
|
import loadTranslations from "./utils/translation";
|
|
3
3
|
import { db } from "./utils/db";
|
|
4
4
|
import { useLiveQuery } from "dexie-react-hooks";
|
|
5
|
+
import { OutletContext } from "../components";
|
|
5
6
|
|
|
6
7
|
const useTranslation = () => {
|
|
7
8
|
const screenId = btoa(window.location.href);
|
|
8
9
|
const value = JSON?.parse(localStorage.getItem("defaultLang"));
|
|
10
|
+
const { generalData } = useContext(OutletContext);
|
|
9
11
|
|
|
10
12
|
const [defaultLang, setDefaultLang] = useState(value?.slug ?? "en");
|
|
11
13
|
const [isLoading, setIsLoading] = useState(false);
|
|
12
14
|
const [textSchemaLoading, setTextSchemaLoading] = useState(true);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (generalData?.defaultAccount?.language) {
|
|
17
|
+
setDefaultLang(generalData?.defaultAccount?.language);
|
|
18
|
+
}
|
|
19
|
+
}, [generalData]);
|
|
20
|
+
|
|
13
21
|
/**
|
|
14
22
|
* @type {{key: string; value: string; updatedAt: string; screenId: string}[]}
|
|
15
23
|
*/
|