2022-08-17 03:04:06 +02:00
|
|
|
import { GetServerSideProps } from "next";
|
2022-11-21 03:52:24 +01:00
|
|
|
import PersonPage from "../../../components/PersonPage";
|
2022-08-17 03:04:06 +02:00
|
|
|
import fetchAPI from "../../../lib/fetch";
|
2022-11-21 03:52:24 +01:00
|
|
|
import { PartialMember, User } from "../../../lib/types";
|
2022-08-17 03:04:06 +02:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
user: User;
|
2022-11-20 22:05:51 +01:00
|
|
|
partialMembers: PartialMember[];
|
2022-08-17 03:04:06 +02:00
|
|
|
}
|
|
|
|
|
2022-11-21 03:57:30 +01:00
|
|
|
export default function Index({ user }: Props) {
|
2022-11-21 03:52:24 +01:00
|
|
|
return <PersonPage person={user} />;
|
2022-08-17 03:04:06 +02:00
|
|
|
}
|
|
|
|
|
2022-11-20 16:04:53 +01:00
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
2022-11-21 01:58:17 +01:00
|
|
|
const name = context.params!.user;
|
2022-11-20 16:04:53 +01:00
|
|
|
try {
|
2022-11-21 03:57:30 +01:00
|
|
|
const user = await fetchAPI<User>(`/users/${name}`);
|
|
|
|
return { props: { user } };
|
2022-11-20 16:04:53 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
return { notFound: true };
|
|
|
|
}
|
2022-11-18 14:11:52 +01:00
|
|
|
};
|