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/User.jsx | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 client/src/admin/jsx/User.jsx

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

diff --git a/client/src/admin/jsx/User.jsx b/client/src/admin/jsx/User.jsx
new file mode 100644
index 0000000..22b96b4
--- /dev/null
+++ b/client/src/admin/jsx/User.jsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import { WithHover, t } from '../hocs';
+import logout from '../api/logout';
+
+const User = ({ user, setUser, opened, setOpened }) => {
+  const handleLogout = () => {
+    setOpened(false);
+    logout();
+  };
+  const handleChangePass = () => { setOpened(false) };
+  const handleRemoveUser = () => { setOpened(false) };
+
+  return (
+    <div className="user">
+      <WithHover message="click-to-change-user">
+        <span
+          className={`user__main-item${opened === 'user' ? ' user__main-item--active' : ''}`}
+          onClick={() => setOpened(opened !== 'user' ? 'user' : false)}
+        >
+          {user}
+        </span>
+        {
+          opened === 'user' && (
+            <div className="user__list" >
+              <WithHover message="click-to-logout">
+                <span className="user__item" onClick={handleLogout}>{t('logout')}</span>
+              </WithHover>
+              <WithHover message="click-to-change-user-settings">
+                <span className="user__item" onClick={handleChangePass}>{t('user-settings')}</span>
+              </WithHover>
+            </div>
+          )
+        }
+      </WithHover>
+    </div>
+  );
+};
+
+export default User;
-- 
cgit v1.2.3

