Projekt

Obecné

Profil

Stáhnout (2.49 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { Form, Input, Button } from 'antd';
2
import { UserOutlined, LockOutlined } from '@ant-design/icons';
3
import 'antd/dist/antd.css';
4
import LoginLayout from '../../layouts/loginLayout';
5

    
6
/**
7
 * Creates a login screen.
8
 * @returns Html structure of the login screen.
9
 */
10
function Login() {
11
    /**
12
     * Handles submission a form when its fields were successfully validated.
13
     * @param values Fields of the login form.
14
     */
15
    const onFinish = (values: any) => {
16
        /**
17
         @todo: delete login form log when login API is implemented
18
        **/
19
        console.log('Values of the login form: ', values);
20
    };
21

    
22
    /**
23
     * Handles submission a form when its validation failed.
24
     * @param errorInfo Validation errors.
25
     */
26
    const onFinishFailed = (errorInfo: any) => {
27
        /**
28
         @todo: delete log when error handling is implemented
29
        **/
30
        console.log('Errors: ', errorInfo);
31
    };
32

    
33
    return (
34
        <LoginLayout>
35
            <Form
36
                name="login"
37
                onFinish={onFinish}
38
                onFinishFailed={onFinishFailed}
39
                autoComplete="off"
40
            >
41
                <Form.Item
42
                    name="email"
43
                    rules={[
44
                        {
45
                            required: true,
46
                            message: 'Prosím zadejte svůj email',
47
                        },
48
                        {
49
                            type: 'email',
50
                            message:
51
                                'Prosím zadejte svůj email ve formátu: "jmeno@example.com"',
52
                        },
53
                    ]}
54
                >
55
                    <Input
56
                        prefix={<UserOutlined className="site-form-item-icon" />}
57
                        placeholder="Email"
58
                    />
59
                </Form.Item>
60

    
61
                <Form.Item
62
                    name="password"
63
                    rules={[{ required: true, message: 'Prosím zadejte své heslo' }]}
64
                >
65
                    <Input.Password
66
                        prefix={<LockOutlined className="site-form-item-icon" />}
67
                        placeholder="Heslo"
68
                    />
69
                </Form.Item>
70
                <Form.Item>
71
                    <Button type="primary" htmlType="submit" className="w-100">
72
                        Přihlásit
73
                    </Button>
74
                </Form.Item>
75
            </Form>
76
        </LoginLayout>
77
    );
78
}
79

    
80
export default Login;
    (1-1/1)