Skip to content

Instantly share code, notes, and snippets.

@Firenox89
Created September 29, 2019 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Firenox89/8b3207e712b00637cc7a8cebe059aa39 to your computer and use it in GitHub Desktop.
Save Firenox89/8b3207e712b00637cc7a8cebe059aa39 to your computer and use it in GitHub Desktop.
Am I Doing this Right?
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