ListCard.js 924 Bytes
Newer Older
이재연's avatar
0113    
이재연 committed
1
import React, { useState, useEffect, useRef } from 'react';
kusang96's avatar
kusang96 committed
2
import { Card, Button } from 'react-bootstrap';
이재연's avatar
0113    
이재연 committed
3

4
function ListCard({ id, name, price, main_img }) {
이재연's avatar
0113    
이재연 committed
5

kusang96's avatar
kusang96 committed
6
7
8
9
10
11
    function handleDelete(e) {
        const card = e.target.parentNode.parentNode
        alert('해당 상품을 성공적으로 삭제하였습니다.')
        card.remove()
    }

이재연's avatar
0113    
이재연 committed
12
    return (
kusang96's avatar
kusang96 committed
13
        <Card id={id} className="m-3" style={{ width: "18rem" }}>
14
            <Card.Img variant="top" src={main_img && `/images/${main_img}`} style={{ objectFit: "contain", height: "22rem" }} />
이재연's avatar
0113    
이재연 committed
15
            <Card.Body>
16
17
                <Card.Title style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{name}</Card.Title>
                <Card.Text>{price} </Card.Text>
18
                {/* <Button className="float-right" onClick={handleDelete}>삭제</Button> */}
이재연's avatar
0113    
이재연 committed
19
            </Card.Body>
20
        </Card>
이재연's avatar
0113    
이재연 committed
21
    )
kusang96's avatar
kusang96 committed
22
}
이재연's avatar
0113    
이재연 committed
23
24

export default ListCard