Prioritizes published teams over unpublished ones (#8177)

pull/8190/head^2
Omar López 2023-04-10 23:16:57 -07:00 committed by GitHub
parent 543e526568
commit 636ee7b8a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -157,16 +157,20 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const ssr = await ssrInit(context);
const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug;
const unpublishedTeam = await prisma.team.findFirst({
where: {
metadata: {
path: ["requestedSlug"],
equals: slug,
},
},
});
const team = await getTeamWithMembers(undefined, slug);
if (!team) {
const unpublishedTeam = await prisma.team.findFirst({
where: {
metadata: {
path: ["requestedSlug"],
equals: slug,
},
},
});
if (!unpublishedTeam) return { notFound: true } as const;
if (unpublishedTeam) {
return {
props: {
isUnpublished: true,
@ -176,10 +180,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
} as const;
}
const team = await getTeamWithMembers(undefined, slug);
if (!team) return { notFound: true } as { notFound: true };
team.eventTypes = team.eventTypes.map((type) => ({
...type,
users: type.users.map((user) => ({