import Link from 'next/link' import { 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' const Admin = props => { const [isOpen, setIsOpen] = useState(false) const toggleModal = () => setIsOpen(!isOpen) return ( <> {/* Création d'une fonction */} {isOpen ? (

Crée une nouvelle fonction

) : (

Administration

)} ) } export async function getServerSideProps (context) { const cookies = new Cookies(context.req.headers.cookie) const user = { ...cookies.get('user') } if (!user.isAdmin) { return redirect(context, '/404') } return { props: { user } } } export default Admin