-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
23,698 additions
and
1,654 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,74 @@ | ||
import React from "react" | ||
import '../index.css'; | ||
import { Menu, Item, MenuProvider } from 'react-contexify'; | ||
import 'react-contexify/dist/ReactContexify.min.css'; | ||
import auth from './auth'; | ||
import cogoToast from 'cogo-toast'; | ||
|
||
|
||
|
||
|
||
import React from "react"; | ||
import "../index.css"; | ||
import { Menu, Item, MenuProvider } from "react-contexify"; | ||
import "react-contexify/dist/ReactContexify.min.css"; | ||
import auth from "./auth"; | ||
import cogoToast from "cogo-toast"; | ||
|
||
function LogoutMenu() { | ||
|
||
|
||
|
||
function onClick() { | ||
|
||
localStorage.removeItem('typerex_username') | ||
localStorage.removeItem('wpm') | ||
localStorage.removeItem('isLoggedin') | ||
window.location.href = '/Typerex/'; | ||
|
||
} | ||
|
||
function deleteAccount() { | ||
const username = localStorage.getItem('typerex_username') | ||
localStorage.removeItem('typerex_username') | ||
localStorage.removeItem('wpm') | ||
localStorage.removeItem('isLoggedin') | ||
setTimeout(function(){window.location.href = '/Typerex/'},1000) | ||
auth.userDelete(username) | ||
.then(() => { | ||
cogoToast.warn( | ||
<div> | ||
<div><b>Account with {username} is deleted ☠️</b></div> | ||
</div>,{ hideAfter:3}, | ||
); | ||
}) | ||
.catch(e => { | ||
console.log(e) | ||
}) | ||
} | ||
|
||
return ( | ||
<Menu id='menu_id' > | ||
<Item onClick={onClick}>🚶Logout</Item> | ||
<Item onClick={deleteAccount}>⚠️ Delete Account</Item> | ||
</Menu> | ||
|
||
) | ||
function onClick() { | ||
localStorage.removeItem("typerex_username"); | ||
localStorage.removeItem("wpm"); | ||
localStorage.removeItem("isLoggedin"); | ||
window.location.href = "/Typerex/"; | ||
} | ||
|
||
function deleteAccount() { | ||
const username = localStorage.getItem("typerex_username"); | ||
localStorage.removeItem("typerex_username"); | ||
localStorage.removeItem("wpm"); | ||
localStorage.removeItem("isLoggedin"); | ||
setTimeout(function () { | ||
window.location.href = "/Typerex/"; | ||
}, 1000); | ||
auth | ||
.userDelete(username) | ||
.then(() => { | ||
cogoToast.warn( | ||
<div> | ||
<div> | ||
<b>Account with {username} is deleted ☠️</b> | ||
</div> | ||
</div>, | ||
{ hideAfter: 3 } | ||
); | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
}); | ||
} | ||
|
||
return ( | ||
<Menu id="menu_id"> | ||
<Item onClick={onClick}>🚶Logout</Item> | ||
</Menu> | ||
); | ||
} | ||
|
||
|
||
|
||
|
||
const Header = (props) => ( | ||
<nav> | ||
<div className="nav"> | ||
<div className='user-item'></div> | ||
<div className="nav-item"> | ||
<a | ||
href="/Typerex/" | ||
style={{ textDecoration: "none", color: "white" }} | ||
> | ||
|
||
Typerex | ||
</a> | ||
</div> | ||
<div className='user-item-main'> | ||
<div className='user-item-sub'> | ||
<MenuProvider id="menu_id" event="onClick"> | ||
<> | ||
<p style={{marginBottom:'0'}}><b id='username'></b></p> | ||
<p id='user-wpm' style={{margin:'0'}}></p> | ||
<LogoutMenu /> | ||
</> | ||
</MenuProvider> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
|
||
|
||
) | ||
|
||
export default Header | ||
<nav> | ||
<div className="nav"> | ||
<div className="user-item"></div> | ||
<div className="nav-item"> | ||
<a href="/Typerex/" style={{ textDecoration: "none", color: "white" }}> | ||
Typerex | ||
</a> | ||
</div> | ||
<div className="user-item-main"> | ||
<div className="user-item-sub"> | ||
<MenuProvider id="menu_id" event="onClick"> | ||
<> | ||
<p style={{ marginBottom: "0" }}> | ||
<b id="username"></b> | ||
</p> | ||
<p id="user-wpm" style={{ margin: "0" }}></p> | ||
<LogoutMenu /> | ||
</> | ||
</MenuProvider> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
); | ||
|
||
export default Header; |
Oops, something went wrong.