import React, { useState, useEffect } from 'react'; import Menu from '../Components/Menu'; import axios from 'axios'; import 'bootstrap/dist/css/bootstrap.css'; function ACheck(props) { const [reserve, setReserve] = useState([]); useEffect(() => { getReserve(); }, []) function getReserve() { axios.get(`/admin/`, { // 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) }); } 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) }); }; function admit(index) { axios.put(`/reserves/${reserve[index].approve}`) .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.user} {reserve.date} {reserve.time} {reserve.room} {reserve.num}
) } export default ACheck