diff --git a/src/pages/users/[id].tsx b/src/pages/users/[id].tsx index f7550d1..c180656 100644 --- a/src/pages/users/[id].tsx +++ b/src/pages/users/[id].tsx @@ -1,5 +1,47 @@ +import useTimeDistance from '@/hooks/utilities/useTimeDistance'; +import findUserById from '@/services/User/findUserById'; +import GetUserSchema from '@/services/User/schema/GetUserSchema'; +import { format } from 'date-fns'; +import { GetServerSideProps } from 'next'; import { FC } from 'react'; +import { z } from 'zod'; -const UserInfoPage: FC = () => null; +interface UserInfoPageProps { + user: z.infer; +} + +const UserInfoPage: FC = ({ user }) => { + const timeDistance = useTimeDistance(new Date(user.createdAt)); + return ( +
+

+ {user.firstName} {user.lastName} +

+

+ joined{' '} + {' '} + ago +

+
+ ); +}; export default UserInfoPage; + +export const getServerSideProps: GetServerSideProps = async ( + context, +) => { + const { id } = context.params!; + const user = await findUserById(id as string); + + if (!user) { + return { notFound: true }; + } + + return { props: { user: JSON.parse(JSON.stringify(user)) } }; +};