Add logout
This commit is contained in:
parent
695927b9e8
commit
13e2851e4c
|
@ -3,7 +3,7 @@ import PropTypes from "prop-types";
|
||||||
|
|
||||||
export default (player) => {
|
export default (player) => {
|
||||||
function Login(props) {
|
function Login(props) {
|
||||||
const [input, setInput] = useState(localStorage.getItem("token"));
|
const [input, setInput] = useState(localStorage.getItem("token") ? localStorage.getItem("token"): "" );
|
||||||
return (
|
return (
|
||||||
<div className="login">
|
<div className="login">
|
||||||
<input type="text" placeholder="Token ID" value={input}
|
<input type="text" placeholder="Token ID" value={input}
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
export default () => function MainApp() {
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
function MainApp(props) {
|
||||||
return (
|
return (
|
||||||
<div className="main">
|
<div className="main">
|
||||||
|
<header>
|
||||||
|
<p>Questable</p>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
props.setLoggedIn(false);
|
||||||
|
localStorage.removeItem("token");
|
||||||
|
}}>Logout</button>
|
||||||
|
</header>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
MainApp.propTypes = {
|
||||||
|
setLoggedIn: PropTypes.func,
|
||||||
|
};
|
||||||
|
return MainApp;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ const MainApp = mainapp();
|
||||||
|
|
||||||
function App(){
|
function App(){
|
||||||
const [loggedIn, setLoggedIn] = useState(false);
|
const [loggedIn, setLoggedIn] = useState(false);
|
||||||
return loggedIn ? <MainApp /> : <Login setLoggedIn={setLoggedIn} />;
|
return loggedIn ? <MainApp setLoggedIn={setLoggedIn} /> : <Login setLoggedIn={setLoggedIn} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById("root"));
|
ReactDOM.render(<App />, document.getElementById("root"));
|
||||||
|
|
Loading…
Reference in New Issue