mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user