pronounsfu/frontend/pages/u/[user]/index.tsx

25 lines
646 B
TypeScript
Raw Normal View History

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