Signup.js 8.55 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

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

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

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

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

        console.log(fullAddress);
    }

    const Postcode = () => {

이재연's avatar
이재연 committed
37

이재연's avatar
이재연 committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
        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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    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
79

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

                            <Form.Group controlId="formBasicAdd">
                                <Form.Row>
이재연's avatar
이재연 committed
172
173
174
175
                                    {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
176
                                        {post}
이재연's avatar
이재연 committed
177
178
                                    <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
179
                                        <Form.Control.Feedback type="invalid" > 상세 주소를 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
180
181
182
                                </Form.Row>
                            </Form.Group>

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

                    </Col>
                </Row>

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

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

export default Signup