From 5bc2917e78c133cd8966a65aa200588eb6d7c0d6 Mon Sep 17 00:00:00 2001
From: Piotr Russ <mail@pruss.it>
Date: Fri, 27 Nov 2020 00:38:22 +0100
Subject: save language in login & admin apps

---
 client/src/admin/jsx/App.jsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'client/src/admin/jsx/App.jsx')

diff --git a/client/src/admin/jsx/App.jsx b/client/src/admin/jsx/App.jsx
index 3a4da84..1bb224f 100644
--- a/client/src/admin/jsx/App.jsx
+++ b/client/src/admin/jsx/App.jsx
@@ -8,7 +8,7 @@ import Info from './Info.jsx';
 import MainScreen from './MainScreen.jsx';
 import Context from '../context';
 import { defaultLanguage } from '../data/translations';
-import { getUser } from '../api';
+import { getUser, setDbLang } from '../api';
 
 const App = () => {
   const [lang, setLang] = useState(defaultLanguage);
@@ -18,6 +18,11 @@ const App = () => {
   const [view, setView] = useState('main');
   const [user, setUser] = useState(null);
 
+  const setLangWithDb = (key) => {
+    setLang(key)
+    setDbLang(key);
+  };
+
   useEffect(() => {
     getUser(setUser);
     setInfo('no-saved-websites');
@@ -30,7 +35,7 @@ const App = () => {
   return (
     <Context.Provider value={{ lang, setHover, setInfo }}>
       <div className="main">
-        <TopBar lang={lang} setLang={setLang} user={user} setUser={setUser} />
+        <TopBar lang={lang} setLang={setLangWithDb} user={user} setUser={setUser} />
         <div className="main__content">
           { view === 'main' && <MainScreen projects={projects} /> }
         </div>
-- 
cgit v1.2.3

