fix(frontend): remove redundant member list fetch

This commit is contained in:
hanabi 2022-11-20 21:57:30 -05:00
parent befd3f15ee
commit 3a640e4bcd
1 changed files with 3 additions and 13 deletions

View File

@ -8,25 +8,15 @@ interface Props {
partialMembers: PartialMember[];
}
export default function Index({ user, partialMembers }: Props) {
export default function Index({ user }: Props) {
return <PersonPage person={user} />;
}
export const getServerSideProps: GetServerSideProps = async (context) => {
const name = context.params!.user;
try {
const [userResponse, partialMembersResponse] = await Promise.allSettled([
fetchAPI<User>(`/users/${name}`),
fetchAPI<PartialMember[]>(`/users/${name}/members`),
]);
if (userResponse.status === "rejected")
throw new Error("Could not fetch user");
const user = userResponse.value;
const partialMembers =
partialMembersResponse.status === "fulfilled"
? partialMembersResponse.value
: [];
return { props: { user, partialMembers } };
const user = await fetchAPI<User>(`/users/${name}`);
return { props: { user } };
} catch (e) {
console.log(e);
return { notFound: true };