Payment.js 7.85 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
Kim, Subin's avatar
Kim, Subin committed
2
3
import MainNav from '../Components/MainNav';
import SubNav from '../Components/SubNav';
Jiwon Yoon's avatar
Jiwon Yoon committed
4
import DaumPostcode from "react-daum-postcode";
5
import { Container, Card, Row, Col, Button, Form } from 'react-bootstrap';
Kim, Subin's avatar
Kim, Subin committed
6
7
8

function Payment() {

9
    const [paymentWay, setPaymentWay] = useState([])
Jiwon Yoon's avatar
Jiwon Yoon committed
10
11
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
    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 = {
        display: "block",
        position: "absolute",
        // top: "50%",
        width: "400px",
        height: "500px",
        padding: "7px",
    };
55
56

    function handleClick() {
Jiwon Yoon's avatar
Jiwon Yoon committed
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        if (paymentWay.length !== 0) {
            setPaymentWay([])
        }
        else {
            const a = (
                <div>
                    <Form>
                        <Form.Group controlId="exampleForm.ControlSelect1">
                            <Form.Label>입금은행</Form.Label>
                            <Form.Control as="select" placeholder="입금은행을 선택하세요.">
                                <option>농협 / 352-0559-2528-83 / 김수빈</option>
                                <option>우리은행 / 0000-000-000000 / 이재연</option>
                                <option>국민은행 / 111111-11-111111 / 윤대기</option>
                            </Form.Control>
                        </Form.Group>
                        <Form.Group controlId="formName">
                            <Form.Label>입금자</Form.Label>
                            <Form.Control type="email" placeholder="윤지원" />
                        </Form.Group>
                        <Form.Group controlId="formDay">
                            <Form.Label>입금예정일</Form.Label>
                            <Form.Control type="date" />
                        </Form.Group>
                    </Form>
                </div>)
            setPaymentWay(a)
        }
    }

87
    function handleClick2() {
88
89
90
91
92
        if (paymentWay.length !== 0) {
            setPaymentWay([])
        }
    }

Kim, Subin's avatar
Kim, Subin committed
93
94
    return (
        <div>
Kim, Subin's avatar
Kim, Subin committed
95
96
            <MainNav />
            <SubNav />
97
            <Container>
Jiwon Yoon's avatar
Jiwon Yoon committed
98
                <h3 className="my-5 font-weight-bold text-center">주문/결제</h3>
99
                <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
100
                    <h5 className="font-weight-bold py-3 border-top border-bottom text-center" style={{ background: '#F7F3F3' }}>주문자 정보</h5>
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
                    <Form>
                        <Form.Group controlId="formBasicName">
                            <Form.Label>이름</Form.Label>
                            <Form.Control type="text" placeholder="윤지원" />
                        </Form.Group>
                        <Form.Group controlId="formBasicEmail">
                            <Form.Label>이메일</Form.Label>
                            <Form.Control type="email" placeholder="jiwon5393@naver.com" />
                        </Form.Group>
                        <Form.Group controlId="formBasicTel">
                            <Form.Label>휴대전화</Form.Label>
                            <Form.Control type="tel" placeholder="010-0000-0000" />
                        </Form.Group>
                    </Form>

                </div>

                <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
119
120
121
122
123
124
125
                    <h5 className="font-weight-bold py-3 border-top border-bottom text-center" style={{ background: '#F7F3F3' }}>배송지 정보</h5>
                    <Row>

                        <Col>
                            <Button className="my-3" style={{ background: "#91877F", borderColor: '#91877F' }} onClick={postClick}>우편번호</Button>
                        </Col>
                    </Row>
Jiwon Yoon's avatar
Jiwon Yoon committed
126
                    {post}
127
128
129
                </div>

                <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
130
                    <h5 className="font-weight-bold py-3 border-top border-bottom text-center" style={{ background: '#F7F3F3' }}>주문상품정보</h5>
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
                    <Card >
                        <Row>
                            <Col className="text-center align-self-center">
                                <input className="" type="checkbox" id="exampleCheck1"></input>

                            </Col>
                            <Col>
                                <Card.Img className="img-fluid" variant="top" src="img/asd.jpg" style={{ width: '20rem' }} />
                            </Col>
                            <Col>
                                <Card.Body>
                                    <img src="https://img.icons8.com/fluent-systems-regular/24/000000/close-window.png" className="float-right" />
                                    <Card.Title className="font-weight-bold mt-3">제품명</Card.Title>
                                    <Card.Text>가격</Card.Text>
                                    <Card.Text>옵션</Card.Text>
Jiwon Yoon's avatar
Jiwon Yoon committed
146
147
148
149
                                    <div className="align-items-center" >
                                        <input type="image" src="https://img.icons8.com/ios-glyphs/20/000000/minus-math.png" />
                                        <input type="text"  placeholder="1"  style={{ width: '30px' }} className="text-center align-middle mx-1" readOnly></input>
                                        <input type="image" src="https://img.icons8.com/ios-glyphs/20/000000/plus-math.png" />
150
151
152
153
154
155
156
                                    </div>
                                </Card.Body>
                            </Col>
                        </Row>
                    </Card>
                </div>

Jiwon Yoon's avatar
Jiwon Yoon committed
157
                <div className="p-5 m-5" style={{ background: '#F7F3F3' }}>
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
                    <ul className="pl-0" style={{ listStyle: 'none' }}>
                        <li>
                            <span className="text-secondary"> 상품금액</span>
                            <span className="text-secondary float-right">12,000</span>
                        </li>
                        <li>
                            <span className="text-secondary">배송비</span>
                            <span className="text-secondary float-right">2,500</span>
                        </li>
                    </ul>
                    <div className="my-1 pt-2 border-top font-weight-bold">
                        결제금액<span className="float-right">14,500</span>
                    </div>
                </div>

                <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
174
                    <h5 className="font-weight-bold py-3 border-top border-bottom text-center" style={{ background: '#F7F3F3' }}>결제수단</h5>
175
176
177
178
179
180
181
182
                    <div className="text-center">
                        <Button variant="success" onClick={handleClick} >무통장입금</Button>
                        <Button variant="warning" style={{ color: '#ffffff' }} onClick={handleClick2}>카카오페이</Button>
                    </div>
                    {paymentWay}

                </div>
            </Container>
Kim, Subin's avatar
Kim, Subin committed
183
184
185
186
187
        </div>
    )
}

export default Payment