SignUpPage.js 4.7 KB
Newer Older
우지원's avatar
ul    
우지원 committed
1
import React, { useState } from 'react';
2
import { Button, Form, Container, Navbar } from 'react-bootstrap';
우지원's avatar
ul    
우지원 committed
3
import { Link } from 'react-router-dom';
Choi Ga Young's avatar
Choi Ga Young committed
4
import Menu from '../Components/Menu';
우지원's avatar
ul    
우지원 committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18

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

    const handleSubmit = (event) => {
        const form = event.currentTarget;
        if (form.checkValidity() === false) {
            event.preventDefault();
            event.stopPropagation();
        }

        setValidated(true);
    };

우지원's avatar
a    
우지원 committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// async function addUser(user) {
//     await fetch(`http://localhost:3000/users`, {
//         method: 'POST',
//         headers: {
//             'Content-Type' : 'application/json'
//          },
//         body: JSON.stringify(user)
//         //json 형식으로 보냄.
//     })
// }

    function submitUser() {
        const username = document.querySelector('#username')
        const nickname = document.querySelector('#nickname')
        const email = document.querySelector('#email')
        const password = document.querySelector('#password')

        const user = {
            username: username.value,
            nickname: nickname.value,
            email: email.value,
            password: password.value
        }

        console.log(user);
    }



우지원's avatar
ul    
우지원 committed
48
    return (
49
        <>
우지원's avatar
병합    
우지원 committed
50
51
52
53
            <Navbar bg="dark" variant="dark">
                <Navbar.Brand>YDK Messenger</Navbar.Brand>
            </Navbar>

우지원's avatar
ul    
우지원 committed
54

55
56
57
58
            <div>
                <Form noValidate validated={validated} onSubmit={handleSubmit}>
                    <Container className="d-flex justify-content-center">
                        <div className="mt-5 p-5 shadow w-75">
우지원's avatar
ul    
우지원 committed
59

60
61
62
63
64
65
66
                            <h2 className="text-center ">회원가입</h2>

                            <Form.Group controlId="formGroupUsername">
                                <Form.Label>이름</Form.Label>
                                <Form.Control
                                    required
                                    type="text"
우지원's avatar
a    
우지원 committed
67
                                    id="username"
68
69
70
                                    placeholder="이름을 입력해주세요" />
                                <Form.Control.Feedback type="invalid">
                                    필수 정보입니다! 이름을 입력해주세요!
우지원's avatar
ul    
우지원 committed
71
                            </Form.Control.Feedback>
72
                            </Form.Group>
우지원's avatar
ul    
우지원 committed
73

74
75
76
77
78
                            <Form.Group controlId="formGroupNickname">
                                <Form.Label>별명</Form.Label>
                                <Form.Control
                                    required
                                    type="text"
우지원's avatar
a    
우지원 committed
79
                                    id="nickname"
80
81
82
                                    placeholder="별명을 입력해주세요" />
                                <Form.Control.Feedback type="invalid">
                                    필수 정보입니다! 별명을 입력해주세요!
우지원's avatar
ul    
우지원 committed
83
                            </Form.Control.Feedback>
84
                            </Form.Group>
우지원's avatar
ul    
우지원 committed
85

86
87
88
89
                            <Form.Group controlId="formGroupEmail">
                                <Form.Label>이메일</Form.Label>
                                <Form.Control
                                    required
우지원's avatar
a    
우지원 committed
90
91
                                    type="email"
                                    id="email"
92
93
94
                                    placeholder="이메일을 입력해주세요" />
                                <Form.Control.Feedback type="invalid">
                                    필수 정보입니다! 이메일을 입력해주세요!
우지원's avatar
a    
우지원 committed
95
                            </Form.Control.Feedback>
96
                            </Form.Group>
우지원's avatar
ul    
우지원 committed
97

98
99
100
101
                            <Form.Group controlId="formGroupPassword">
                                <Form.Label>비밀번호</Form.Label>
                                <Form.Control
                                    required
우지원's avatar
a    
우지원 committed
102
103
                                    type="password"
                                    id="password"
104
105
106
                                    placeholder="비밀번호를 입력해주세요" />
                                <Form.Control.Feedback type="invalid">
                                    필수 정보입니다! 비밀번호를 입력해주세요!
우지원's avatar
ul    
우지원 committed
107
                            </Form.Control.Feedback>
108
                            </Form.Group>
우지원's avatar
ul    
우지원 committed
109

우지원's avatar
a    
우지원 committed
110
111
112

                            <Link to="./login">
                                <Button type="submit" onClick={{submitUser}} variant="outline-success" size="lg" className="mr-4" block>가입</Button>
113
114
115
116
117
118
                            </Link>
                        </div>
                    </Container>
                </Form>
            </div >
        </>
우지원's avatar
ul    
우지원 committed
119
120
121
122
    )
}

export default SingUp