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