Login.js 3.17 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
2
3
import { Link, Redirect } from 'react-router-dom';
import { Form, Col, Container, Button, Row } from 'react-bootstrap';
이재연's avatar
logsign    
이재연 committed
4

이재연's avatar
이재연 committed
5
6
7
8
9
10
function Login(){

    const [validated,setValidated]=useState(false);

    const handleSubmit=(e)=>{
        const form =e.currentTarget;
이재연's avatar
이재연 committed
11
        if(form.checkValidity() === false){  //checkValidity 는 입력 요소에 유효한 데이터가 포함되어 있는지 확인
이재연's avatar
이재연 committed
12
13
14
15
16
            e.preventDefault();
            e.stopPropagation();
        }
        setValidated(true);
    }
Jiwon Yoon's avatar
22    
Jiwon Yoon committed
17
    
Kim, Subin's avatar
Kim, Subin committed
18
    return (
이재연's avatar
logsign    
이재연 committed
19
        <div>
Jiwon Yoon's avatar
22    
Jiwon Yoon committed
20

이재연's avatar
logsign    
이재연 committed
21
22
            <Container className="my-5">
                <Row className="justify-content-center">
이재연's avatar
이재연 committed
23
                    <Col md={5} xs={10} className="border" style={{ background: '#F7F3F3' }}>
이재연's avatar
logsign    
이재연 committed
24
                        <h3 className="text-center mt-5">Login</h3>
이재연's avatar
이재연 committed
25
                        <Form  noValidate validated={validated} onSubmit={handleSubmit} className="p-5">
이재연's avatar
logsign    
이재연 committed
26
27
                            <Form.Group controlId="formBasicId">
                                <Form.Row>
이재연's avatar
이재연 committed
28
29
30
                                    <Col sm={4} xs={6} as={Form.Label} for="id"> 아이디</Col>
                                        <Col sm={8} xs={12} as={Form.Control}
                                            required
이재연's avatar
이재연 committed
31
32
                                            type="text"
                                            id="id"
이재연's avatar
이재연 committed
33
34
35
36
                                            placeholder="ID"
                                            style={{ width: '160px' }}>
                                        </Col>
                                        <Form.Control.Feedback className="text-center" type="invalid"> 아이디를 입력하세요.</Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
37
38
39
40
41
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicPassword">
                                <Form.Row>
이재연's avatar
이재연 committed
42
43
                                    <Col sm={4} xs={6} as={Form.Label} for="password">비밀번호</Col>
                                        <Col sm={8} xs={12} as={Form.Control}
이재연's avatar
이재연 committed
44
45
                                            type="password"
                                            id="password"
이재연's avatar
이재연 committed
46
47
48
49
50
51
                                            placeholder="Password"
                                            style={{ width: '160px' }}
                                            required />
                                    <Form.Control.Feedback className="text-center" type="invalid">
                                        비밀번호를 입력하세요.
                                    </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
52
53
                                </Form.Row>
                            </Form.Group>
이재연's avatar
이재연 committed
54
                            <Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block>Login</Button>
이재연's avatar
logsign    
이재연 committed
55
                            <div className="loginLine">
이재연's avatar
이재연 committed
56
                                <Link to="/signup" style={{ color: '#91877F' }}>회원이 아니십니까?</Link>
이재연's avatar
logsign    
이재연 committed
57
58
59
60
61
62
                            </div>
                        </Form>
                    </Col>
                </Row>
            </Container>
        </div>
Kim, Subin's avatar
Kim, Subin committed
63
64
65
66
    )
}

export default Login