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

Kim, Subin's avatar
Kim, Subin committed
7

이재연's avatar
이재연 committed
8
9
10
function Login(authenticated,login,location) {
    const [id, setId] = useState("");
    const [password,setPassword]= useState("");
Kim, Subin's avatar
Kim, Subin committed
11

이재연's avatar
이재연 committed
12
13
14
15
16
17
18
19
20
    const handleClick =() => {
        try {
            Login({id,password})
        } catch(e) {
            alert("Failed to login")
            setId("")
            setPassword("")
        }
    }
이재연's avatar
logsign    
이재연 committed
21

Kim, Subin's avatar
Kim, Subin committed
22
    return (
이재연's avatar
logsign    
이재연 committed
23
        <div>
Kim, Subin's avatar
Kim, Subin committed
24
25
            <Nav1 />
            <Nav2 />
이재연's avatar
logsign    
이재연 committed
26
27
28
29
30
31
32
33
34
35
36
37
            <Container className="my-5">
                <Row className="justify-content-center">

                    <Col md={5} xs={10} className="border">
                        <h3 className="text-center mt-5">Login</h3>
                        <Form className="p-5">


                            <Form.Group controlId="formBasicId">
                                <Form.Row>
                                    <Form.Label for="id">User Name</Form.Label>
                                    <Col>
이재연's avatar
이재연 committed
38
39
40
41
42
43
                                        <Form.Control 
                                        type="text" 
                                        value={id} 
                                        onChange={({target:{value}})=>setId(value)} 
                                        className="mx-sm-3" size="sm" placeholder="User Name">
                                        </Form.Control>
이재연's avatar
logsign    
이재연 committed
44
45
46
47
48
49
50
51
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicPassword">
                                <Form.Row>
                                    <Form.Label for="password">Password</Form.Label>
                                    <Col>
이재연's avatar
이재연 committed
52
53
54
55
56
                                        <Form.Control 
                                        type="password" 
                                        value={password}
                                        onChange={({target:{value}})=>setPassword(value)} 
                                        className="mx-sm-3" size="sm" placeholder="Password"></Form.Control>
이재연's avatar
logsign    
이재연 committed
57
58
59
                                    </Col>
                                </Form.Row>
                            </Form.Group>
이재연's avatar
이재연 committed
60
                            <Button variant="outline-dark" type="submit" onClick={handleClick} block>Login</Button>
이재연's avatar
logsign    
이재연 committed
61
62
63
64
65
66
67
68
69
70
71
72
73
                            <div className="loginLine">
                                <Link to="/signup">SignUp?</Link>
                            </div>
                        </Form>
                    </Col>
                </Row>




            </Container>
        </div>

이재연's avatar
2    
이재연 committed
74

Kim, Subin's avatar
Kim, Subin committed
75
76
77
78
    )
}

export default Login