Created
September 29, 2019 10:25
-
-
Save Firenox89/8b3207e712b00637cc7a8cebe059aa39 to your computer and use it in GitHub Desktop.
Am I Doing this Right?
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
import React, {useState} from 'react'; | |
import {TextField, Button, Link, Box, Container, Typography, Grid} from '@material-ui/core'; | |
import {login, getAccounts} from './APIHelper' | |
let loginField = ""; | |
let password = ""; | |
export default function App() { | |
const [isLoggedIn, setIsLoggedIn] = useState(false); | |
return ( | |
<Container maxWidth="sm"> | |
{isLoggedIn ? | |
<Grid | |
container | |
direction="column" | |
justify="center" | |
alignItems="center" | |
> | |
<Button variant="contained" color="primary" onClick={() => getAccounts()}> | |
GetAccs | |
</Button> | |
<Button variant="contained" color="primary" onClick={() => setIsLoggedIn(false)}> | |
Logout | |
</Button> | |
</Grid> | |
: | |
<Grid | |
container | |
direction="column" | |
justify="center" | |
alignItems="center" | |
> | |
<Typography variant="h4" component="h1" gutterBottom> | |
Login | |
</Typography> | |
<TextField id="login" type="string" label="Login" | |
onChange={event => loginField = event.target.value}/> | |
<TextField id="password" type="password" label="Password" | |
onChange={event => password = event.target.value}/> | |
<Button variant="contained" color="primary" | |
onClick={() => login(loginField, password, setIsLoggedIn)}> | |
Login | |
</Button> | |
</Grid> | |
} | |
</Container> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment