Last change
on this file since 17abe5e was 17abe5e, checked in by i-ina <76742075+i-ina@…>, 3 years ago |
react components for details and bugfix
|
-
Property mode
set to
100644
|
File size:
2.2 KB
|
Rev | Line | |
---|
[3f5bf9e] | 1 | import React from 'react';
|
---|
| 2 | import {useHistory} from 'react-router-dom';
|
---|
| 3 | import {Button, Checkbox, Container, Form} from "semantic-ui-react";
|
---|
| 4 |
|
---|
| 5 | const Login = (props) => {
|
---|
| 6 | const history = useHistory();
|
---|
| 7 | const [formData, updateFormData] = React.useState({
|
---|
[17abe5e] | 8 | email: "",
|
---|
[3f5bf9e] | 9 | password: "",
|
---|
[17abe5e] | 10 | type: "0"
|
---|
[3f5bf9e] | 11 | })
|
---|
| 12 |
|
---|
| 13 | const handleCheck = (e, {value}) => {
|
---|
| 14 | updateFormData({
|
---|
| 15 | ...formData,
|
---|
| 16 | [e.target.name]: value
|
---|
| 17 | })
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | const onFormSubmit = (e) =>{
|
---|
| 21 | e.preventDefault();
|
---|
[17abe5e] | 22 | const email = formData.email;
|
---|
[3f5bf9e] | 23 | const password = formData.password;
|
---|
| 24 | const type = formData.type;
|
---|
| 25 |
|
---|
[17abe5e] | 26 | props.onCompleteForm(email,password,type);
|
---|
[3f5bf9e] | 27 | history.push("/");
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | return(
|
---|
| 31 | <Container>
|
---|
| 32 | <Form onSubmit={onFormSubmit}>
|
---|
[17abe5e] | 33 | <Form.Input id="email" name="email" type='text' required fluid label='E-mail' placeholder='Enter e-mail.' onChange={handleCheck} />
|
---|
[3f5bf9e] | 34 | <Form.Input id="password" name="password" type='password' required fluid label='Password' placeholder='Enter password.' onChange={handleCheck} />
|
---|
| 35 | <Form.Field
|
---|
| 36 | control={Checkbox}
|
---|
| 37 | radio
|
---|
| 38 | label='User'
|
---|
| 39 | id="0"
|
---|
[17abe5e] | 40 | name="type"
|
---|
| 41 | value="0"
|
---|
[3f5bf9e] | 42 | checked={formData.type === "0"}
|
---|
| 43 | onChange={handleCheck}
|
---|
| 44 | />
|
---|
| 45 | <Form.Field
|
---|
| 46 | control={Checkbox}
|
---|
| 47 | radio
|
---|
| 48 | label='Team'
|
---|
| 49 | id="1"
|
---|
[17abe5e] | 50 | name="type"
|
---|
| 51 | value="1"
|
---|
[3f5bf9e] | 52 | checked={formData.type === "1"}
|
---|
| 53 | onChange={handleCheck}
|
---|
| 54 | />
|
---|
| 55 | <Form.Field
|
---|
| 56 | control={Checkbox}
|
---|
| 57 | radio
|
---|
| 58 | label='Company'
|
---|
| 59 | id="2"
|
---|
[17abe5e] | 60 | name="type"
|
---|
| 61 | value="2"
|
---|
[3f5bf9e] | 62 | checked={formData.type === "2"}
|
---|
| 63 | onChange={handleCheck}
|
---|
| 64 | />
|
---|
| 65 | <Form.Field control={Button}>LogIn</Form.Field>
|
---|
| 66 | </Form>
|
---|
| 67 | </Container>
|
---|
| 68 | );
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | export default Login; |
---|
Note:
See
TracBrowser
for help on using the repository browser.