import React, { useState, useEffect } from 'react'; import Menu from '../Components/Menu'; import axios from 'axios'; import { Link, Redirect } from 'react-router-dom'; import { Container, Row, Col, Card, Accordion, Button } from 'react-bootstrap'; import CARD from '../Components/Card'; function Notice() { const [show, setShow] = useState(false); const [notices, setNotices] = useState([]); const [user, setUser] = useState({ role: "" }) const [state, setState] = useState() useEffect(() => { acheck(); getNotice(); }, []); if (state) return ; function acheck() { axios.get(`/users/${localStorage.getItem('_id')}`, { headers: { authorization: localStorage.getItem('token') }, }) .then(res => { if (res.status !== 201) { alert(res.data.error); localStorage.clear(); setState(true); } if (res.data.role == "admin") { setUser(res.data) } }).catch(err => { alert(err.error) }); } function getNotice() { axios.get(`/notices`) .then(res => { if (res.status !== 201) { // alert(res.data.error); } setNotices(res.data); }) .catch(err => { alert(err.error) }); } return (

공지사항 {user.role === "admin" ? ( ) : null}

{notices.map((notice, index) => )}
) } export default Notice;