-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#333: Merged develop and fixed conflicts in index css
- Loading branch information
Showing
7 changed files
with
147 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,28 @@ | ||
import "../index.css"; | ||
import React, { useState } from "react"; | ||
import { SNOWPACK_PUBLIC_API_URL } from "../utils"; | ||
import down from "../icons/caret-down-fill.svg"; | ||
import { AuthContext } from "../components/AuthProvider"; | ||
|
||
export const HeaderUser = ({ username }: { username: string }) => { | ||
const { logoutBackend, setUser } = React.useContext(AuthContext); | ||
|
||
const [showUserSettings, setShowUserSettings] = useState<boolean>(false); | ||
|
||
const showSettingsClickHandle = () => { | ||
setShowUserSettings(!showUserSettings); | ||
}; | ||
|
||
const logout = async (e) => { | ||
const logout = await logoutBackend(); | ||
if (logout) setUser(null); | ||
}; | ||
|
||
const showSettings = () => { | ||
return ( | ||
<ul className="settings-box" aria-labelledby="dropdownMenuLink"> | ||
<li className="settings-list-item"> | ||
<a className="dropdown-item settings-list-link" href="/report"> | ||
Report time | ||
</a> | ||
<a className="dropdown-item settings-list-link" href="/help"> | ||
Help | ||
</a> | ||
<a className="dropdown-item settings-list-link" onClick={logout}> | ||
Logout | ||
</a> | ||
</li> | ||
</ul> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="p-2 settings-wrapper"> | ||
<a | ||
className="btn dropdown-button" | ||
onClick={showSettingsClickHandle} | ||
data-toggle="dropdown" | ||
aria-haspopup="true" | ||
aria-expanded={showUserSettings} | ||
> | ||
{username} | ||
{showUserSettings ? ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
> | ||
<path d="m7.247 4.86-4.796 5.481c-.566.647-.106 1.659.753 1.659h9.592a1 1 0 0 0 .753-1.659l-4.796-5.48a1 1 0 0 0-1.506 0z" /> | ||
</svg> | ||
) : ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
> | ||
<path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z" /> | ||
</svg> | ||
)} | ||
<nav className="nav-wrapper"> | ||
<div className="nav-user">{username}</div> | ||
<div className="nav-bar">|</div> | ||
<button type="button" className="nav-item" onClick={logout}> | ||
Log out | ||
</button> | ||
<a className="nav-item" href="/help"> | ||
Help | ||
</a> | ||
<a className="nav-item" href="/report"> | ||
Report time | ||
</a> | ||
{showUserSettings ? showSettings() : null} | ||
</div> | ||
</nav> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters