import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
import { Redirect } from 'react-router-dom';
import axios from 'axios';
import { Container, Table } from 'react-bootstrap';
import styled from 'styled-components';
const Ta = styled(Table)`
margin-top: 0.5em;
& th, & td {
padding: 0;
vertical-align: middle;
font-size: 0.9rem;
margin-left : auto; margin-right : auto;
border-spacing: initial;
};
& tr {
display: d-flex;
width: 150px;
};
& td {
align-items: center;
margin: 10px;
};
`
function Check(props) {
const [reserve, setReserve] = useState([]);
const [state, setState] = useState()
useEffect(() => {
getReserve();
}, [])
if (state) return ;
function getReserve() {
axios.get(`/reserves/${props.match.params.id}`, {
headers: { authorization: localStorage.getItem('token') },
})
.then(res => {
if (res.status === 404) {
alert(res.data.error);
}
if (res.status === 419) {
alert(res.data.error);
localStorage.clear();
setState(true);
}
const reserves = res.data.filter(function(item) {
return item !== '';
});
setReserve(reserves);
})
.catch(err => {
alert(err.error)
});
}
function remove(index) {
axios.delete(`/reserves/${reserve[index]._id}`)
.then(res => {
if (res.status === 404) return alert(res.data.error)
alert("삭제되었습니다!");
getReserve();
})
.catch(err => {
alert(err.error)
});
};
return (
날짜 |
시간 |
강의실 |
사용인원 |
{/* 승인여부 | */}
예약취소 |
{reserve.map((reserve, index) => {
return (
{reserve.date} |
{reserve.starttime}시~{(Number(reserve.starttime) + reserve.usetime)}시 |
{reserve.room} |
{reserve.num} |
{/* {reserve.check ? (reserve.approve ? "사용가능" : "사용불가") : "승인대기중"} | */}
|
)
})}
)
}
export default Check