import Link from 'next/link'; import { Fragment, useState } from 'react'; import Cookies from "universal-cookie"; import HeadTag from '../../components/HeadTag'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTimes } from '@fortawesome/free-solid-svg-icons'; import Modal from '../../components/Modal'; import FunctionsList from '../../components/FunctionsList/FunctionsList'; import AddEditFunction from '../../components/FunctionAdmin/AddEditFunction'; import redirect from '../../utils/redirect'; import '../../public/css/pages/admin.css'; const Admin = (props) => { const [isOpen, setIsOpen] = useState(false); const toggleModal = () => setIsOpen(!isOpen); if (!props.user.isAdmin && typeof window != 'undefined') { return redirect({}, '/404'); } return ( {/* Création d'une fonction */} {(isOpen) ?

Crée une nouvelle fonction

:

Administration

}
); } export async function getServerSideProps({ req }) { const cookies = new Cookies(req.headers.cookie); return { props: { user: { ...cookies.get('user') } } }; } export default Admin;