import React, { useState, useEffect } from 'react'; import Menu from '../Components/Menu'; import axios from 'axios'; import { Redirect } from 'react-router-dom'; import { Container, Table } from 'react-bootstrap'; import styled from 'styled-components'; const Ta = styled(Table)` & th, & td { padding: 0; vertical-align: middle; }; & tr { display: d-flex; width: 50px; }; & td { align-items: center; width: 70px; }; ` function ACheck(props) { const [state, setState] = useState() const [reserve, setReserve] = useState([]); useEffect(() => { getReserve(); }, []) function getReserve() { axios.get(`/users/admin/${props.match.params.id}`, { headers: { authorization: localStorage.getItem('token') }, }) .then(res => { if (res.status === 404) { alert(res.data.error) setState(true); } setReserve(res.data); }) .catch(err => { alert(err.error) }); } if (state) return ; function remove(index) { axios.put(`/reserves/${reserve[index]._id}`) .then(res => { if (res.status === 404) return alert(res.data.error) alert("승인을 거절했습니다!"); getReserve(); }) .catch(err => { alert(err.error) }); }; function admit(index) { axios.put(`/reserves/${reserve[index]._id}`, { approve: true, }) .then(res => { if (res.status === 404) return alert(res.data.error) alert("승인되었습니다!"); getReserve(); }) .catch(err => { alert(err.error) }); }; return (
대표자 날짜 시간 강의실 사용 인원 승인 여부 {reserve != "" ? ( reserve.map((reserve, index) => { return ( {reserve.user.name} {reserve.date} {reserve.starttime}시~{(Number(reserve.starttime) + reserve.usetime)}시 {reserve.room} {reserve.num} ) })) :
최근 대관 신청 내역이 없습니다.
}
) } export default ACheck