Signup.js 7.93 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
이재연's avatar
..    
이재연 committed
2
import { Redirect } from 'react-router-dom';
Kim, Subin's avatar
Kim, Subin committed
3
4
import Nav1 from '../Components/MainNav';
import Nav2 from '../Components/SubNav';
이재연's avatar
logsign    
이재연 committed
5
import { Form, Col, Container, Button, Row } from 'react-bootstrap'
이재연's avatar
이재연 committed
6
import FormCheckInput from 'react-bootstrap/esm/FormCheckInput';
이재연's avatar
이재연 committed
7
8
import DaumPostcode from "react-daum-postcode";

Kim, Subin's avatar
Kim, Subin committed
9
10
11

function Signup() {

이재연's avatar
이재연 committed
12
13
14
15
16
17
18
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    const [isAddress, setIsAddress] = useState("");
    const [isZoneCode, setIsZoneCode] = useState();
    const [isPostOpen, setIsPostOpen] = useState();
    const [post, setPost] = useState([]);

    function postClick() {
        if (post.length !== 0) {
            setPost([])
        } else {
            setPost(
                <div>
                    <DaumPostcode style={postCodeStyle} onComplete={handleComplete} />
                </div>
            )

        }
    }

    const handleComplete = (data) => {
        let fullAddress = data.address;
        let extraAddress = "";

        if (data.addressType === "R") {
            if (data.bname !== "") {
                extraAddress += data.bname;
            }
            if (data.buildingName !== "") {
                extraAddress +=
                    extraAddress !== "" ? `, ${data.buildingName}` : data.buildingName;
            }
            fullAddress += extraAddress !== "" ? ` (${extraAddress})` : "";
        }
        setIsZoneCode(data.zonecode);
        setIsAddress(fullAddress);
        setIsPostOpen(false);
    };

    const postCodeStyle = {
        position: "absolute",
        width: "400px",
        height: "500px",
        padding: "7px",
    };


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

    const handleSubmit = (e) => {
        const form = e.currentTarget;
        console.log(form)
        if (form.checkValidity() === false) {
            e.preventDefault();
            e.stopPropagation();
        }
        setValidated(true);
    }
이재연's avatar
..    
이재연 committed
68

Kim, Subin's avatar
Kim, Subin committed
69
    return (
이재연's avatar
logsign    
이재연 committed
70
        <div>
이재연's avatar
이재연 committed
71

Kim, Subin's avatar
Kim, Subin committed
72
73
            <Nav1 />
            <Nav2 />
이재연's avatar
logsign    
이재연 committed
74
75
            <Container className="my-5">
                <Row className="justify-content-center">
이재연's avatar
이재연 committed
76
                    <Col md={6} xs={10} className="border" style={{ background: '#F7F3F3' }}>
이재연's avatar
logsign    
이재연 committed
77
78
                        <h2 className="text-center mt-5">Sign Up</h2>

이재연's avatar
이재연 committed
79
                        <Form noValidate validated={validated} onSubmit={handleSubmit} className="p-5">
이재연's avatar
logsign    
이재연 committed
80
81
82
83
84



                            <Form.Group controlId="formBasicName">
                                <Form.Row>
이재연's avatar
이재연 committed
85
                                    <Form.Label for="name"> </Form.Label>
이재연's avatar
logsign    
이재연 committed
86
87

                                    <Col>
이재연's avatar
이재연 committed
88
89
90
91
92
93
                                        <Form.Control
                                            required
                                            type="text" id="name"
                                            size="sm" placeholder="" className="mx-sm-3">
                                        </Form.Control>
                                        <Form.Control.Feedback type="invalid">이름을 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
94
95
96
97
98
99
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicNumber">
                                <Form.Row>
이재연's avatar
이재연 committed
100
                                    <Form.Label for="number">주민등록번호</Form.Label>
이재연's avatar
logsign    
이재연 committed
101
102

                                    <Col as={Row}>
이재연's avatar
이재연 committed
103
                                        <Form.Control required type="text" id="number1" size="sm" maxlength="6" className="mx-sm-3" style={{ width: '120px' }}></Form.Control>
이재연's avatar
logsign    
이재연 committed
104
                                    -
이재연's avatar
이재연 committed
105
                                    <Form.Control required type="text" id="number2" size="sm" maxlength="1" className="mx-sm-3" style={{ width: '25px' }}></Form.Control>
이재연's avatar
logsign    
이재연 committed
106
                                    ******
이재연's avatar
이재연 committed
107
                                    <Form.Control.Feedback type="invalid">주민등록번호를 입력하세요.</Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
108
109
110
111
                                    </Col>

                                </Form.Row>
                            </Form.Group>
이재연's avatar
이재연 committed
112
113
114
115
116
                            <Form.Group controlId="formBasicId">
                                <Form.Row>
                                    <Form.Label for="id">아이디</Form.Label>

                                    <Col>
이재연's avatar
이재연 committed
117
118
                                        <Form.Control required type="text" id="id" size="sm" placeholder="ID" className="mx-sm-3"></Form.Control>
                                        <Form.Control.Feedback type="invalid"> 아이디를 입력하세요.</Form.Control.Feedback>
이재연's avatar
이재연 committed
119
120
121
                                    </Col>
                                </Form.Row>
                            </Form.Group>
이재연's avatar
logsign    
이재연 committed
122
123
124

                            <Form.Group controlId="formBasicPassword">
                                <Form.Row>
이재연's avatar
이재연 committed
125
                                    <Form.Label for="password">비밀번호</Form.Label>
이재연's avatar
logsign    
이재연 committed
126
127

                                    <Col>
이재연's avatar
이재연 committed
128
                                        <Form.Control required type="password" id="password" size="sm" placeholder="Password" aria-describedby="passwordHelpBlock" className="mx-sm-3"></Form.Control>
이재연's avatar
이재연 committed
129
                                        <Form.Text id="password" muted> 8-15자로 입력해주세요.</Form.Text>
이재연's avatar
이재연 committed
130
131
                                        <Form.Control.Feedback type="invalid"> 비밀번호를 입력하세요.
                                    </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
132
133
134
135
136
137
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicPassword2">
                                <Form.Row>
이재연's avatar
이재연 committed
138
                                    <Form.Label for="password2">비밀번호 확인</Form.Label>
이재연's avatar
logsign    
이재연 committed
139
140

                                    <Col>
이재연's avatar
이재연 committed
141
142
143
                                        <Form.Control required type="password" id="password2" size="sm" placeholder="" className="mx-sm-3"></Form.Control>
                                        <Form.Control.Feedback type="invalid"> 비밀번호를 한번  입력하세요.
                                    </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
144
145
146
147
148
149
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicTel">
                                <Form.Row>
이재연's avatar
이재연 committed
150
                                    <Form.Label for="tel">휴대전화</Form.Label>
이재연's avatar
logsign    
이재연 committed
151
152

                                    <Col>
이재연's avatar
이재연 committed
153
154
                                        <Form.Control required type="text" id="tel" size="sm" placeholder="" className="mx-sm-3"></Form.Control>
                                        <Form.Control.Feedback type="invalid"> 휴대전화를 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
155
156
157
158
159
160
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicAdd">
                                <Form.Row>
이재연's avatar
이재연 committed
161
                                    <Form.Label> </Form.Label>
이재연's avatar
logsign    
이재연 committed
162
163

                                    <Col>
이재연's avatar
이재연 committed
164
165
166
167
                                        <button type="button" onClick={postClick}>우편번호 찾기</button>
                                        {post}
                                        <Form.Control required type="text" id="add2" size="sm" placeholder="상세주소" className="mx-sm-3"></Form.Control>
                                        <Form.Control.Feedback type="invalid" > 상세 주소를 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
168
169
170
171
                                    </Col>
                                </Form.Row>
                            </Form.Group>

이재연's avatar
이재연 committed
172
                            <Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block>Sign Up</Button>
이재연's avatar
logsign    
이재연 committed
173
174
175
176
177
178
179
                        </Form>

                    </Col>
                </Row>

            </Container>
        </div>
이재연's avatar
..    
이재연 committed
180

Kim, Subin's avatar
Kim, Subin committed
181
182
183
184
    )
}

export default Signup