ListCard.js 7.12 KB
Newer Older
kusang96's avatar
kusang96 committed
1
import React from 'react';
kusang96's avatar
card    
kusang96 committed
2
import { Row, Col, Card } from 'react-bootstrap';
이재연's avatar
0113    
이재연 committed
3

kusang96's avatar
card    
kusang96 committed
4
function ListCard(props) {
kusang96's avatar
kusang96 committed
5

kusang96's avatar
card    
kusang96 committed
6
7
8
9
10
11
12
13
14
15
16
17
    if (props.status === 'list') {
        return (
            <Card id={props.id} className="m-3" style={{ width: "18rem" }}>
                <Card.Img variant="top" src={props.main_img && `/images/${props.main_img}`} style={{ objectFit: "contain", height: "22rem" }} />
                <Card.Body>
                    <Card.Title style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{props.name}</Card.Title>
                    <Card.Text>{props.price} </Card.Text>
                </Card.Body>
            </Card>
        )
    } else if (props.status === 'recommend') {
        return (
kusang96's avatar
kusang96 committed
18
            <Card id={props.id} className="mx-1" style={{ width: "10rem" }}>
kusang96's avatar
card    
kusang96 committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
                <Card.Img variant="top" src={props.main_img && `/images/${props.main_img}`} style={{ objectFit: "contain" }} />
                <Card.Body className="px-0">
                    <Card.Title style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{props.name}</Card.Title>
                    <Card.Text>{props.price} </Card.Text>
                </Card.Body>
            </Card>
        )
    } else if (props.status === 'order') {
        return (
            <Card >
                <Card.Title className="font-weight-bold mt-4 text-center"> 주문 현황</Card.Title>
                {
                    props.ordered.map((e) => (
                        <Card.Body className='m-1'>
                            {e.products.length > 1 ?
                                <Card.Header className="font-weight-bold mb-3 text-center" style={{ background: '#F7F3F3' }}>
                                    {e.products[0].productId.pro_name}  {e.products.length - 1}
                                    </Card.Header>
                                : (
                                    <Card.Header className="font-weight-bold mb-3 text-center" style={{ background: '#F7F3F3' }}>
                                        {e.products[0].productId.pro_name}
                                    </Card.Header>)}
                            <Card.Text>
42
43
44
45
46
47
48
49
                            <Col className='justify-content-center'>
                                <Row className='justify-content-center' >
                                    <>
                                        <Col sm={3} xs={5} className='p-1'><li>주문번호 :</li></Col>
                                        <Col sm={8} xs={6} className='p-1'><strong>{e._id}</strong></Col>
                                    </>
                                    <Col sm={3} xs={5} className='p-1'><li>결제금액 :</li></Col>
                                    <Col sm={8} xs={6} className='p-1'><strong>{e.total}</strong></Col>
kusang96's avatar
card    
kusang96 committed
50

51
52
                                    <Col sm={3} xs={5} className='p-1'><li>배송지 :</li></Col>
                                    <Col sm={8} xs={6} className='p-1'><strong> {e.receiverInfo.address}</strong> <br />( {e.receiverInfo.address2} )</Col>
kusang96's avatar
card    
kusang96 committed
53

54
55
56
57
                                    <Col sm={3} xs={5} className='p-1'><li>주문날짜 :</li></Col>
                                    <Col sm={8} xs={6} className='p-1'><strong>{e.createdAt.substring(0, 10)}</strong></Col>
                                </Row>
                            </Col>
kusang96's avatar
card    
kusang96 committed
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
                            </Card.Text>
                        </Card.Body>
                    )
                    )
                }
            </Card>
        )
    } else if (props.status === 'cart') {
        return (
            <>
                {props.cart.map((e) => (
                    <Card>
                        <Row className="mx-1">
                            <Col xs={2} sm={2} className="text-center my-auto">
                                <input className="" type="checkbox" name={String(e._id)} onChange={props.checkedCart} />
                            </Col>
                            <Col className="text-center">
                                <Card.Img className="img-fluid" variant="top" src={e.productId.main_imgUrl && `/images/${e.productId.main_imgUrl}`} style={{ width: '20rem' }} />
                            </Col>
                            <Col md={6} className="p-2">
                                <Card.Body>
                                    <input type="image" name={String(e._id)} alt="삭제버튼" src="https://img.icons8.com/fluent-systems-regular/24/000000/close-window.png" className="float-right" onClick={props.deleteCart} />
                                    <Card.Title className="font-weight-bold mt-3">{e.productId.pro_name}</Card.Title>
                                    <Card.Text className="mb-0">가격: {e.productId.price}</Card.Text>
                                    <Card.Text className="mb-0">옵션: {e.size}/{e.color}</Card.Text>
                                    <Card.Text >수량</Card.Text>
                                    <div>
                                        <input type="image" name={String(e._id)} alt="마이너스" src="https://img.icons8.com/ios-glyphs/20/000000/minus-math.png" className="align-middle" onClick={props.minusNum} />
                                        <input type="number" style={{ width: '30px' }} className="text-center align-middle mx-1" placeholder={e.count} value={e.count} readOnly></input>
                                        <input type="image" name={String(e._id)} alt="플러스" src="https://img.icons8.com/ios-glyphs/20/000000/plus-math.png" className="align-middle" onClick={props.plusNum} />
                                    </div>
                                </Card.Body>
                            </Col>
                        </Row>
                    </Card>
                ))
                }
            </>
        )
    } else if (props.status === 'payment') {
        return (
            <>
                {props.cart.map((e) => (
                    <Card>
                        <Row className="mx-1">
                            <Col className="text-center">
                                <Card.Img className="img-fluid" variant="top" src={e.productId.main_imgUrl && `/images/${e.productId.main_imgUrl}`} style={{ width: '20rem' }} />
                            </Col>
                            <Col md={6} className="p-2">
                                <Card.Body>
                                    <input type="image" name={String(e._id)} alt="삭제버튼" src="https://img.icons8.com/fluent-systems-regular/24/000000/close-window.png" className="float-right" onClick={props.deleteOrder} />
                                    <Card.Title className="font-weight-bold mt-3">{e.productId.pro_name}</Card.Title>
                                    <Card.Text>가격: {e.productId.price}</Card.Text>
                                    <Card.Text>옵션: {e.size}/{e.color}</Card.Text>
                                    <Card.Text>수량: {e.count}</Card.Text>
                                </Card.Body>
                            </Col>
                        </Row>
                    </Card>
                ))
                }
            </>
        )
    }
kusang96's avatar
kusang96 committed
122
}
이재연's avatar
0113    
이재연 committed
123
124

export default ListCard