CheckPage.js 1.13 KB
Newer Older
Ha YeaJin's avatar
pages    
Ha YeaJin committed
1
2
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
3
4
import List from '../Components/List';
import axios from 'axios';
Ha YeaJin's avatar
pages    
Ha YeaJin committed
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function Check(props) {
    function getReserve() {
        axios.get(`/reserves/${props.match.params.id}`, {
            headers: { authorization: localStorage.getItem('token') },
        })
            .then(res => {
                if (res.status !== 201) {
                    alert(res.data.error);
                }
                console.log(res.data);
                setReserve(res.data);
            })
            .catch(err => {
                alert(err.error)
            });
    }

    const [reserve, setReserve] = useState([]);
    useEffect(() => {
        getReserve();
    }, [])
Ha YeaJin's avatar
pages    
Ha YeaJin committed
27
28
29
30
    return (
        <div>
            <Menu />
            <div className="container">check
31
32
33
            {reserve.map((reserve, index) =>
                <List id={props.match.params.id} index={index} date={reserve.date} name={reserve.name} room={reserve.room} time={reserve.time} num={reserve.num} _id={reserve._id}/>
            )}
Ha YeaJin's avatar
pages    
Ha YeaJin committed
34
35
36
37
38
39
            </div>
        </div>
    )
}

export default Check