From 636ee7b8a13ca4e83bd9c354d04f5daef75c937e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Mon, 10 Apr 2023 23:16:57 -0700 Subject: [PATCH] Prioritizes published teams over unpublished ones (#8177) --- apps/web/pages/team/[slug].tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/web/pages/team/[slug].tsx b/apps/web/pages/team/[slug].tsx index 1261bf7554..68f0914d1a 100644 --- a/apps/web/pages/team/[slug].tsx +++ b/apps/web/pages/team/[slug].tsx @@ -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) => ({