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
Garcia
authored and
Garcia
committed
Oct 15, 2020
1 parent
545eb18
commit 1d58b99
Showing
4 changed files
with
94 additions
and
34 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
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,29 +1,52 @@ | ||
import React from 'react' | ||
import { Container, Form, Button } from 'react-bootstrap' | ||
import { loginUser } from '../../requests/UserRequests' | ||
import { Redirect } from 'react-router-dom' | ||
|
||
const loginPage = () => { | ||
return ( | ||
<Container> | ||
<Form className='mt-5'> | ||
<Form.Group controlId="formBasicEmail"> | ||
<Form.Label>Email address</Form.Label> | ||
<Form.Control type="email" placeholder="Enter email" /> | ||
<Form.Text className="text-muted"> | ||
We'll never share your email with anyone else. | ||
</Form.Text> | ||
</Form.Group> | ||
class LoginPage extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
|
||
<Form.Group controlId="formBasicPassword"> | ||
<Form.Label>Password</Form.Label> | ||
<Form.Control type="password" placeholder="Password" /> | ||
</Form.Group> | ||
this.state = { | ||
email: '', | ||
password: '', | ||
redirect: false | ||
} | ||
} | ||
|
||
<Button variant="primary" type="submit"> | ||
Login | ||
</Button> | ||
</Form> | ||
</Container> | ||
) | ||
submit(evt) { | ||
evt.preventDefault() | ||
loginUser(this.state.email, this.state.password) | ||
.then(_ => { | ||
this.setState({redirect: true}) | ||
}) | ||
.catch(_ => { | ||
alert("not good") | ||
}) | ||
} | ||
|
||
render() { | ||
return ( | ||
<Container> | ||
<Form className='mt-5'> | ||
<Form.Group controlId="formBasicEmail"> | ||
<Form.Label>Email address</Form.Label> | ||
<Form.Control onChange={(evt) => this.setState({email: evt.target.value})} value={this.state.email} type="email" placeholder="Enter email" /> | ||
</Form.Group> | ||
|
||
<Form.Group controlId="formBasicPassword"> | ||
<Form.Label>Password</Form.Label> | ||
<Form.Control onChange={(evt) => this.setState({password: evt.target.value})} value={this.state.password} type="password" placeholder="Password" /> | ||
</Form.Group> | ||
|
||
{this.state.redirect && <Redirect to="/dashboard" />} | ||
<Button onClick={(evt) => this.submit(evt)} variant="primary" type="submit"> | ||
Login | ||
</Button> | ||
</Form> | ||
</Container> | ||
) | ||
} | ||
} | ||
|
||
export default loginPage | ||
export default LoginPage |
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