Signup.js 8.48 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>
Kim, Subin's avatar
Kim, Subin committed
81
82
            <Nav1 />
            <Nav2 />
이재연's avatar
logsign    
이재연 committed
83
84
            <Container className="my-5">
                <Row className="justify-content-center">
이재연's avatar
이재연 committed
85
                    <Col md={6} xs={10} className="border" style={{ background: '#F7F3F3' }}>
이재연's avatar
logsign    
이재연 committed
86
                        <h2 className="text-center mt-5">Sign Up</h2>
이재연's avatar
이재연 committed
87
                        <Form noValidate validated={validated} onSubmit={handleSubmit} className="p-5">
이재연's avatar
logsign    
이재연 committed
88
89
                            <Form.Group controlId="formBasicName">
                                <Form.Row>
이재연's avatar
이재연 committed
90
                                    <Form.Label for="name"> </Form.Label>
이재연's avatar
logsign    
이재연 committed
91
                                    <Col>
이재연's avatar
이재연 committed
92
93
94
95
96
97
                                        <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
98
99
100
101
102
103
                                    </Col>
                                </Form.Row>
                            </Form.Group>

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

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

                                    <Col>
이재연's avatar
이재연 committed
120
121
                                        <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
122
123
124
                                    </Col>
                                </Form.Row>
                            </Form.Group>
이재연's avatar
logsign    
이재연 committed
125
126
127

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

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

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

                                    <Col>
이재연's avatar
이재연 committed
144
145
146
                                        <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
147
148
149
150
151
152
                                    </Col>
                                </Form.Row>
                            </Form.Group>

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

                                    <Col>
이재연's avatar
이재연 committed
156
157
                                        <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
158
159
160
161
162
163
                                    </Col>
                                </Form.Row>
                            </Form.Group>

                            <Form.Group controlId="formBasicAdd">
                                <Form.Row>
이재연's avatar
이재연 committed
164
165
166
167
                                    {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
168
                                        {post}
이재연's avatar
이재연 committed
169
170
                                    <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
171
                                        <Form.Control.Feedback type="invalid" > 상세 주소를 입력하세요. </Form.Control.Feedback>
이재연's avatar
logsign    
이재연 committed
172
173
                                </Form.Row>
                            </Form.Group>
이재연's avatar
이재연 committed
174
                            <Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block>Sign Up</Button>
이재연's avatar
logsign    
이재연 committed
175
176
177
178
179
                        </Form>
                    </Col>
                </Row>
            </Container>
        </div>
Kim, Subin's avatar
Kim, Subin committed
180
181
182
183
    )
}

export default Signup