import { Fragment } from 'react'; import Cookies from "universal-cookie"; import date from 'date-and-time'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faPen, faTrash } from '@fortawesome/free-solid-svg-icons'; import HeadTag from '../../components/HeadTag'; import redirect from '../../utils/redirect'; import useAPI from '../../hooks/useAPI'; import '../../public/css/pages/admin.css'; const manageCategories = (props) => { const [, categories] = useAPI('/categories'); if (!props.user.isAdmin && typeof window != 'undefined') { return redirect({}, '/404'); } return (

Gérer les catégories

{categories.map((category) => { return ( ); })}
id name color createdAt updatedAt Modifier Supprimer
{category.id} {category.name} {category.color} {date.format(new Date(category.createdAt), 'DD/MM/YYYY à HH:mm', true)} {date.format(new Date(category.updatedAt), 'DD/MM/YYYY à HH:mm', true)}
); } export async function getServerSideProps({ req }) { const cookies = new Cookies(req.headers.cookie); return { props: { user: { ...cookies.get('user') } } }; } export default manageCategories;