From 1870f3fdf43707a15fda0f609a021f516f45eb63 Mon Sep 17 00:00:00 2001
From: Piotr Russ <mail@pruss.it>
Date: Wed, 18 Nov 2020 23:15:38 +0100
Subject: finish auth routes, create cookie token, fix folder structure, add
 context to FE

---
 client/src/admin/jsx/LangSwitch.jsx | 42 +++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 client/src/admin/jsx/LangSwitch.jsx

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

diff --git a/client/src/admin/jsx/LangSwitch.jsx b/client/src/admin/jsx/LangSwitch.jsx
new file mode 100644
index 0000000..2494bef
--- /dev/null
+++ b/client/src/admin/jsx/LangSwitch.jsx
@@ -0,0 +1,42 @@
+import React from 'react';
+import { WithHover } from '../hocs';
+import { languages } from '../data/translations.js'
+
+const LangSwitch = ({ lang, setLang, opened, setOpened}) => {
+  const handleSetLang = (key) => {
+    setLang(key);
+    setOpened(false);
+  };
+
+  return (
+    <div className="lang-switch">
+      <WithHover message="click-to-change-language">
+        <span
+          className={`lang-switch__main-item${opened === 'lang' ? ' lang-switch__main-item--active' : ''}`}
+          onClick={() => setOpened(opened !== 'lang' ? 'lang' : false)}
+        >
+          {lang}
+        </span>
+        {
+          opened === 'lang' && (
+            <div className="lang-switch__list">
+              {
+                languages.map(key => key !== lang && (
+                  <span
+                    className="lang-switch__item"
+                    key={key}
+                    onClick={() => handleSetLang(key)}
+                  >
+                    {key}
+                  </span>
+                ))
+              }
+            </div>
+          )
+        }
+      </WithHover>
+    </div>
+  );
+};
+
+export default LangSwitch;
-- 
cgit v1.2.3

