refactor: selected language gets stored in local state, triggering an effect that updates lang value in local storage and change language

This commit is contained in:
utin-francis-peter
2024-06-23 23:27:43 +01:00
parent 8c04f5b3f1
commit 0c4ca9c94d

View File

@@ -84,6 +84,11 @@ const General: React.FC = () => {
fetchPrompts();
}, []);
React.useEffect(() => {
localStorage.setItem('docsgpt-locale', selectedLanguage?.value as string);
changeLanguage(selectedLanguage?.value);
}, [selectedLanguage, changeLanguage]);
return (
<div className="mt-[59px]">
<div className="mb-5">
@@ -114,8 +119,6 @@ const General: React.FC = () => {
selectedValue={selectedLanguage ?? languageOptions[0]}
onSelect={(selectedOption: { label: string; value: string }) => {
setSelectedLanguage(selectedOption);
changeLanguage(selectedOption.value);
localStorage.setItem('docsgpt-locale', selectedOption.value);
}}
size="w-56"
rounded="3xl"