Signup.js 8.49 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';
Kim, Subin's avatar
Kim, Subin committed
5
import { Form, Col, Container, Button, Row } from 'react-bootstrap';
이재연's avatar
이재연 committed
6
7
import DaumPostcode from "react-daum-postcode";

Kim, Subin's avatar
Kim, Subin committed
8
9

function Signup() {
이재연's avatar
이재연 committed
10
    const [address,setAddress] =useState("")
이재연's avatar
이재연 committed
11
12
13
14
15

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

이재연's avatar
이재연 committed
16
17
        console.log(data)

이재연's avatar
이재연 committed
18
19
20
        if (data.addressType === "R") {
            if (data.bname !== "") {
                extraAddress += data.bname;
이재연's avatar
이재연 committed
21
                console.log(extraAddress)
이재연's avatar
이재연 committed
22
23
24
25
26
27
28
            }
            if (data.buildingName !== "") {
                extraAddress +=
                    extraAddress !== "" ? `, ${data.buildingName}` : data.buildingName;
            }
            fullAddress += extraAddress !== "" ? ` (${extraAddress})` : "";
        }
이재연's avatar
이재연 committed
29
30
31
32
33
34
35
        setAddress({full: fullAddress, zone: data.zonecode});

        console.log(fullAddress);
    }

    const Postcode = () => {

이재연's avatar
이재연 committed
36

이재연's avatar
이재연 committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        return (
            <DaumPostcode
                onComplete={handleComplete}
            />
        );
    }


    const [post, setPost] = useState([]);

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

        }
    }
이재연's avatar
이재연 committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    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
78

Kim, Subin's avatar
Kim, Subin committed
79
    return (
이재연's avatar
logsign    
이재연 committed
80
        <div>
이재연's avatar
이재연 committed
81

Kim, Subin's avatar
Kim, Subin committed
82
83
            <Nav1 />
            <Nav2 />
이재연's avatar
logsign    
이재연 committed
84
85
            <Container className="my-5">
                <Row className="justify-content-center">
이재연's avatar
이재연 committed
86
                    <Col md={6} xs={10} className="border" style={{ background: '#F7F3F3' }}>
이재연's avatar
logsign    
이재연 committed
87
88
                        <h2 className="text-center mt-5">Sign Up</h2>

이재연's avatar
이재연 committed
89
                        <Form noValidate validated={validated} onSubmit={handleSubmit} className="p-5">
이재연's avatar
logsign    
이재연 committed
90
91
92
93
94



                            <Form.Group controlId="formBasicName">
                                <Form.Row>
이재연's avatar
이재연 committed
95
                                    <Form.Label for="name"> </Form.Label>
이재연's avatar
logsign    
이재연 committed
96
97

                                    <Col>
이재연's avatar
이재연 committed
98
99
100
101
102
103
                                        <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
104
105
106
107
108
109
                                    </Col>
                                </Form.Row>
                            </Form.Group>

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

                                    <Col as={Row}>
이재연's avatar
이재연 committed
113
                                        <Form.Control required type="text" id="number1" size="sm" maxlength="6" className="mx-sm-3" style={{ width: '120px' }}></Form.Control>
이재연's avatar
logsign    
이재연 committed
114
                                    -
이재연's avatar
이재연 committed
115
                                    <Form.Control required type="text" id="number2" size="sm" maxlength="1" className="mx-sm-3" style={{ width: '25px' }}></Form.Control>
이재연's avatar
logsign    
이재연 committed
116
                                    ******
이재연's avatar
이재연 committed
117
                                    <Form.Control.Feedback type="invalid">주민등록번호를 입력하세요.</Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
118
119
120
121
                                    </Col>

                                </Form.Row>
                            </Form.Group>
이재연's avatar
이재연 committed
122
123
124
125
126
                            <Form.Group controlId="formBasicId">
                                <Form.Row>
                                    <Form.Label for="id">아이디</Form.Label>

                                    <Col>
이재연's avatar
이재연 committed
127
128
                                        <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
129
130
131
                                    </Col>
                                </Form.Row>
                            </Form.Group>
이재연's avatar
logsign    
이재연 committed
132
133
134

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

                                    <Col>
이재연's avatar
이재연 committed
138
                                        <Form.Control required type="password" id="password" size="sm" placeholder="Password" aria-describedby="passwordHelpBlock" className="mx-sm-3"></Form.Control>
이재연's avatar
이재연 committed
139
                                        <Form.Text id="password" muted> 8-15자로 입력해주세요.</Form.Text>
이재연's avatar
이재연 committed
140
141
                                        <Form.Control.Feedback type="invalid"> 비밀번호를 입력하세요.
                                    </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
142
143
144
145
146
147
                                    </Col>
                                </Form.Row>
                            </Form.Group>

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

                                    <Col>
이재연's avatar
이재연 committed
151
152
153
                                        <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
154
155
156
157
158
159
                                    </Col>
                                </Form.Row>
                            </Form.Group>

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

                                    <Col>
이재연's avatar
이재연 committed
163
164
                                        <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
165
166
167
168
169
170
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicAdd">
                                <Form.Row>
이재연's avatar
이재연 committed
171
172
173
174
                                    {console.log("address=", address)}
                                    <Form.Label className="mx-3"> </Form.Label>
                                    <Form.Control required type="text" id="add" size="sm " style={{ width: '120px' }} value={address.zone} disabled={(address.zone == null) ? false : true} ></Form.Control>                                        
                                    <Button size="sm" style={{ background: '#91877F', borderColor: '#91877F' }} className="mx-3" type="button" onClick={postClick}>주소 찾기</Button>
이재연's avatar
이재연 committed
175
                                        {post}
이재연's avatar
이재연 committed
176
177
                                    <Form.Control required type="text" id="add" size="sm " value={address.full} disabled={(address.zone == null) ? false : true} className="mx-3"style={{width:'330px'}}></Form.Control>
                                    <Form.Control required type="text" id="add2" size="sm" placeholder="상세주소" className="mx-sm-3"></Form.Control>
이재연's avatar
이재연 committed
178
                                        <Form.Control.Feedback type="invalid" > 상세 주소를 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
179
180
181
                                </Form.Row>
                            </Form.Group>

이재연's avatar
이재연 committed
182
                            <Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block>Sign Up</Button>
이재연's avatar
logsign    
이재연 committed
183
184
185
186
187
188
189
                        </Form>

                    </Col>
                </Row>

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

Kim, Subin's avatar
Kim, Subin committed
191
192
193
194
    )
}

export default Signup