ShoppingCart.js 3.96 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
4
import { Redirect } from 'react-router-dom';
import MainNav from '../Components/MainNav';
import SubNav from '../Components/SubNav';
5
import { Card, Button, Container, Row, Col } from 'react-bootstrap';
Kim, Subin's avatar
Kim, Subin committed
6
7
8

function ShoppingCart() {

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    const [num, setNum] = useState(0)

    function plusNum() {
        setNum(num + 1)
    }
    function minusNum() {
        if (num === 0) {
            setNum(0)
        }
        else {
            setNum(num - 1)

        }
    }
    function deleteCart() {
        //장바구니 DB에서 해당 항목 삭제 
        console.log('카트에 담긴 항목을 삭제했습니다.')
    }

Kim, Subin's avatar
Kim, Subin committed
28
29
    return (
        <div>
Kim, Subin's avatar
Kim, Subin committed
30
31
            <MainNav />
            <SubNav />
32
            <Container className="justify-content-center">
Jiwon Yoon's avatar
Jiwon Yoon committed
33
                <h3 className="my-5 font-weight-bold text-center">장바구니</h3>
34
                <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
35
                    <h4 className="font-weight-bold py-3 border-top border-bottom text-center" style={{ background: '#F7F3F3' }}>주문상품정보</h4>
36
                    <Card>
37
38
39
40
41
                        <Row className="mx-1">
                            <Col xs={2} sm={2} className="text-center my-auto">
                                <input className="" type="checkbox" id="exampleCheck1" />
                            </Col>
                            <Col className="text-center">
42
43
                                <Card.Img className="img-fluid" variant="top" src="img/asd.jpg" style={{ width: '20rem' }} />
                            </Col>
44
                            <Col md={6} className="p-2">
45
                                <Card.Body>
46
                                    <input type="image" src="https://img.icons8.com/fluent-systems-regular/24/000000/close-window.png" className="float-right" onClick={deleteCart} />
47
48
49
50
                                    <Card.Title className="font-weight-bold mt-3">제품명</Card.Title>
                                    <Card.Text>가격</Card.Text>
                                    <Card.Text>옵션</Card.Text>
                                    <Card.Text>수량</Card.Text>
51
52
53
54
                                    <div>
                                        <input type="image" src="https://img.icons8.com/ios-glyphs/20/000000/minus-math.png" className="align-middle" onClick={minusNum} />
                                        <input type="text" style={{ width: '30px' }} className="text-center align-middle mx-1" placeholder="1" value={num} readOnly></input>
                                        <input type="image" src="https://img.icons8.com/ios-glyphs/20/000000/plus-math.png" className="align-middle" onClick={plusNum} />
55
56
57
58
59
60
                                    </div>
                                </Card.Body>
                            </Col>
                        </Row>
                    </Card>
                </div>
61
                <div className="p-5 m-5" style={{ background: '#F7F3F3' }}>
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
                    <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 className="text-center">
Jiwon Yoon's avatar
Jiwon Yoon committed
77
                    <Button className="px-5" style={{ background: "#91877F", borderColor: '#91877F' }} href="/payment">결제하기</Button>
78
79
80
                </div>
            </Container>

Kim, Subin's avatar
Kim, Subin committed
81
82
83
84
85
        </div>
    )
}

export default ShoppingCart