From e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d Mon Sep 17 00:00:00 2001
From: Piotr Russ <mail@pruss.it>
Date: Mon, 16 Nov 2020 00:10:28 +0100
Subject: api, login, auth

---
 client/src/common/jsx/User.jsx | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 client/src/common/jsx/User.jsx

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

diff --git a/client/src/common/jsx/User.jsx b/client/src/common/jsx/User.jsx
new file mode 100644
index 0000000..8b05d44
--- /dev/null
+++ b/client/src/common/jsx/User.jsx
@@ -0,0 +1,38 @@
+import React from 'react';
+import WithHover from './WithHover.jsx';
+
+const User = ({user, setUser, setHover, t, opened, setOpened}) => {
+  const handleLogout = () => {
+    setOpened(false);
+    setUser(null);
+  };
+  const handleChangePass = () => { setOpened(false) };
+  const handleRemoveUser = () => { setOpened(false) };
+
+  return (
+    <div className="user">
+      <WithHover setHover={setHover} 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 setHover={setHover} message="click-to-logout">
+                <span className="user__item" onClick={handleLogout}>{t('logout')}</span>
+              </WithHover>
+              <WithHover setHover={setHover} 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

