Connect, collaborate, and grow with a community of TypeScript developers
feat: show challenges that have not been completed first (#1441)
Obi Fortunec984c1322aa6
diff --git a/apps/web/src/app/[locale]/explore/_components/explore-slug.tsx b/apps/web/src/app/[locale]/explore/_components/explore-slug.tsxindex 04d20f84..cdfb6e00 100644--- a/apps/web/src/app/[locale]/explore/_components/explore-slug.tsx+++ b/apps/web/src/app/[locale]/explore/_components/explore-slug.tsx@@ -13,13 +13,23 @@ interface ExploreSlugProps {export async function ExploreSlug({ slug }: ExploreSlugProps) {const challenges = await getChallengesByTagOrDifficulty(slug);+ const sortedChallenges = challenges.sort((a, b) => {+ const aHasSuccessfulSubmission = a?.submission?.some((submission) => submission.isSuccessful);+ const bHasSuccessfulSubmission = b?.submission?.some((submission) => submission.isSuccessful);++ if (aHasSuccessfulSubmission && !bHasSuccessfulSubmission) return 1;+ if (!aHasSuccessfulSubmission && bHasSuccessfulSubmission) return -1;++ return 0;+ });+return (<div className="container flex flex-col items-center gap-8 py-5 md:gap-16 md:pb-20"><div className="flex space-y-2"><TypographyH3>{toPascalCase(slug)}</TypographyH3></div><div className="flex w-full flex-wrap justify-center gap-6">- {challenges.map((challenge) => (+ {sortedChallenges.map((challenge) => (<LinkclassName="group block w-[95%] focus:outline-none sm:w-[330px] xl:w-[333px]"href={`/challenge/${challenge.slug}`}