import Link from 'next/link'; import { Fragment } from 'react'; import date from 'date-and-time'; import HeadTag from '../../components/HeadTag'; import FunctionCard from '../../components/FunctionCard/FunctionCard'; import redirect from '../../utils/redirect'; import api from '../../utils/api'; import { API_URL } from '../../utils/config'; import '../../public/css/pages/profile.css'; const Profile = (props) => { // Constantes const createdAt = new Date(props.createdAt); const publicationDate = `${('0'+createdAt.getDate()).slice(-2)}/${('0'+(createdAt.getMonth()+1)).slice(-2)}/${createdAt.getFullYear()}`; return (

Profil de {props.name}

{props.name}
{(props.biography != undefined) &&

{props.biography}

} {(props.email != undefined) &&

Email : {props.email}

}

Date de création : {publicationDate}

{(props.favoritesArray.length > 0) &&

Fonctions en favoris :

{props.favoritesArray.map((favorite) => { return ( ); })}
} {(props.commentsArray.length > 0) &&

Derniers commentaires :

{props.commentsArray.map((comment) => (

Posté sur la fonction  {comment.function.title}  le {date.format(new Date(comment.createdAt), 'DD/MM/YYYY à HH:mm', true)}

"{comment.message}"

))}
}
); } export async function getServerSideProps(context) { const { name } = context.params; return api.get(`/users/${name}`) .then((response) => ({ props: response.data })) .catch(() => redirect(context, '/404')); } export default Profile;