Home.js 4.5 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
2
3
4
import ListCard from '../Components/ListCard';
import axios from 'axios';
import catchError from '../utils/catchErrors';
Kim, Subin's avatar
Kim, Subin committed
5
import { Card, Container, Row } from 'react-bootstrap';
6

Kim, Subin's avatar
Kim, Subin committed
7
8

function Home() {
9
10
    const [productlist, setProductlist] = useState([])
    const [error, setError] = useState('')
kusang96's avatar
kusang96 committed
11

12
13
14
15
16
17
18
19
20
21
22
23
24
    useEffect(() => {
        getProductlist()
    }, [])

    async function getProductlist() {
        try {
            const response = await axios.get(`/api/product/getproduct`)
            console.log(response.data)
            setProductlist(response.data)
        } catch (error) {
            catchError(error, setError)
        }
    }
kusang96's avatar
kusang96 committed
25

Kim, Subin's avatar
Kim, Subin committed
26
27
    return (
        <div>
kusang96's avatar
kusang96 committed
28
29
            <Container className="my-5">
                <div className="my-4">
kusang96's avatar
kusang96 committed
30
                    <h2 style={{ marginRight: "5rem", marginLeft: "3rem", marginBottom: "2rem" }}><u>Best</u></h2>
kusang96's avatar
kusang96 committed
31
                    <Row className="justify-content-center mx-0">
32
                        <ListCard productlist={productlist} />
kusang96's avatar
kusang96 committed
33
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
34
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
35
36
37
38
39
40
41
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
                    </Row>
                </div>
kusang96's avatar
kusang96 committed
42
                <div className="my-4">
kusang96's avatar
kusang96 committed
43
                    <h2 style={{ marginRight: "5rem", marginLeft: "3rem", marginBottom: "2rem", marginTop: "2rem" }}><u>New Arrival</u></h2>
kusang96's avatar
kusang96 committed
44
45
                    <Row className="justify-content-center mx-0">
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
46
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
47
48
49
50
51
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
kusang96's avatar
kusang96 committed
52
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
53
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
54
55
56
57
58
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
kusang96's avatar
kusang96 committed
59
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
60
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
61
62
63
64
65
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
kusang96's avatar
kusang96 committed
66
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
67
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
68
69
70
71
72
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
kusang96's avatar
kusang96 committed
73
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
74
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
75
76
77
78
79
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
kusang96's avatar
kusang96 committed
80
                        <Card className="mx-1 my-2" style={{ width: '18rem' }}>
이재연's avatar
zz    
이재연 committed
81
                            <Card.Img className="img-fluid" variant="top" src="/icon/asd.jpg" />
82
83
84
85
86
87
88
89
                            <Card.Body>
                                <Card.Title className="font-weight-bold">제품명</Card.Title>
                                <Card.Text>가격</Card.Text>
                            </Card.Body>
                        </Card>
                    </Row>
                </div>
            </Container>
Kim, Subin's avatar
Kim, Subin committed
90
91
92
93
94
        </div>
    )
}

export default Home