Connect, collaborate, and grow with a community of TypeScript developers
chore: remove aot checks (#1356)
bautistaaaecac5e9ce3a1
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/getChallengeRouteData.ts b/apps/web/src/app/[locale]/challenge/[slug]/getChallengeRouteData.tsindex d6ac5851..67c9d1f2 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/getChallengeRouteData.ts+++ b/apps/web/src/app/[locale]/challenge/[slug]/getChallengeRouteData.ts@@ -2,8 +2,6 @@ import { type Session } from '@repo/auth/server';import { prisma } from '@repo/db';import { cache } from 'react';import { getAllFlags } from '~/utils/feature-flags';-import { AOT_CHALLENGES } from './aot-slugs';-import { daysAfterDecemberFirst } from '~/utils/aot';import { validateCompilerOptions } from '~/utils/validateCompilerOptions';export type ChallengeRouteData = NonNullable<Awaited<ReturnType<typeof getChallengeRouteData>>>;@@ -11,15 +9,6 @@ export type ChallengeRouteData = NonNullable<Awaited<ReturnType<typeof getChalle// this is to data to populate the description tab (default tab on challenge page)export const getChallengeRouteData = cache(async (slug: string, session: Session | null) => {const featureFlags = await getAllFlags();- const isAotChallenge = AOT_CHALLENGES.includes(slug);-- if (featureFlags.enableHolidayEvent && isAotChallenge) {- const [, day = '1'] = slug.split('-');- const daysPassed = daysAfterDecemberFirst();- if (parseInt(day) > daysPassed + 1) {- throw new Error('Not Available');- }- }const challenge = await prisma.challenge.findFirstOrThrow({where: {diff --git a/apps/web/src/app/[locale]/challenge/[slug]/left-wrapper.tsx b/apps/web/src/app/[locale]/challenge/[slug]/left-wrapper.tsxindex 9df7300a..72f26318 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/left-wrapper.tsx+++ b/apps/web/src/app/[locale]/challenge/[slug]/left-wrapper.tsx@@ -1,18 +1,18 @@'use client';import { usePathname, useRouter } from 'next/navigation';-import { useMemo, type ReactNode, useRef, useState, useEffect, useContext } from 'react';+import { useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';-import { FeatureFlagContext } from '~/app/feature-flag-provider';import { ChallengeTrackNavigation } from '~/app/[locale]/challenge/_components/challenge-track-navigation';+import { FeatureFlagContext } from '~/app/feature-flag-provider';-import { Tabs, TabsContent, TabsList, TabsTrigger } from '@repo/ui/components/tabs';import { cn } from '@repo/ui/cn';+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@repo/ui/components/tabs';import { FlaskConical, History, Text } from '@repo/ui/icons';+import { AOT_CHALLENGES } from './aot-slugs';import type { ChallengeRouteData } from './getChallengeRouteData';import { useTrackNavigationVisiblity } from './use-track-visibility.hook';-import { AOT_CHALLENGES } from './aot-slugs';type Tab = 'description' | 'solutions' | 'submissions';interface Props {@@ -132,8 +132,6 @@ export function LeftWrapper({ children, challenge, track, expandPanel, isDesktop'grid-rows-3 gap-2': isIconOnly,'grid-cols-3 gap-0.5': !isIconOnly,'rounded-tl-xl': !isTrackVisible,- 'grid-cols-2 gap-0.5': isAotChallenge && !isIconOnly,- 'grid-rows-2 gap-2': isAotChallenge && isIconOnly,},)}ref={tabsListRef}@@ -158,24 +156,22 @@ export function LeftWrapper({ children, challenge, track, expandPanel, isDesktop>{isIconOnly ? <Text className="h-4 w-4" /> : 'Description'}</TabsTrigger>- {!isAotChallenge ? (- <TabsTrigger- className={cn(- 'rounded-md duration-300 hover:bg-neutral-200/50 data-[state=active]:bg-neutral-200 dark:hover:bg-neutral-700/50 dark:data-[state=active]:bg-neutral-700',- { 'p-4': isIconOnly },- )}- onClick={() => {- router.push(`/challenge/${challenge.slug}/solutions`);- isCollapsed && expandPanel();- }}- onFocus={(e) => {- e.target.click();- }}- value="solutions"- >- {isIconOnly ? <FlaskConical className="h-4 w-4" /> : 'Solutions'}- </TabsTrigger>- ) : null}+ <TabsTrigger+ className={cn(+ 'rounded-md duration-300 hover:bg-neutral-200/50 data-[state=active]:bg-neutral-200 dark:hover:bg-neutral-700/50 dark:data-[state=active]:bg-neutral-700',+ { 'p-4': isIconOnly },+ )}+ onClick={() => {+ router.push(`/challenge/${challenge.slug}/solutions`);+ isCollapsed && expandPanel();+ }}+ onFocus={(e) => {+ e.target.click();+ }}+ value="solutions"+ >+ {isIconOnly ? <FlaskConical className="h-4 w-4" /> : 'Solutions'}+ </TabsTrigger><TabsTriggerclassName={cn('rounded-md rounded-tr-lg duration-300 hover:bg-neutral-200/50 data-[state=active]:bg-neutral-200 dark:hover:bg-neutral-700/50 dark:data-[state=active]:bg-neutral-700',diff --git a/apps/web/src/app/[locale]/challenge/[slug]/page.tsx b/apps/web/src/app/[locale]/challenge/[slug]/page.tsxindex 42e157fd..6b182f83 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/page.tsx+++ b/apps/web/src/app/[locale]/challenge/[slug]/page.tsx@@ -1,8 +1,5 @@import { auth, type Session } from '@repo/auth/server';-import { notFound } from 'next/navigation';import { buildMetaForChallenge, buildMetaForEventPage } from '~/app/metadata';-import { daysAfterDecemberFirst } from '~/utils/aot';-import { getAllFlags } from '~/utils/feature-flags';import { getRelativeTime } from '~/utils/relativeTime';import { Comments } from '../_components/comments';import { Description } from '../_components/description';@@ -38,24 +35,12 @@ export async function generateMetadata({ params: { slug } }: Props) {export default async function Challenges({ params: { slug } }: Props) {const session = await auth();- const { enableHolidayEvent } = await getAllFlags();- const isAotChallenge = AOT_CHALLENGES.includes(slug);-- if (enableHolidayEvent && isAotChallenge) {- const [, day = '1'] = slug.split('-');- const daysPassed = daysAfterDecemberFirst();-- if (parseInt(day) > daysPassed + 1) {- return notFound();- }- }-const { challenge } = await getChallengeRouteData(slug, session);return (<div className="relative h-full "><Description challenge={challenge} />- {!isAotChallenge ? <Comments rootId={challenge.id} type="CHALLENGE" /> : null}+ <Comments rootId={challenge.id} type="CHALLENGE" /></div>);}diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.tsindex c316b9c6..60983c77 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts@@ -1,4 +1,5 @@'use server';+import { auth } from '@repo/auth/server';import { prisma } from '@repo/db';import { revalidateTag } from 'next/cache';import type { ChallengeRouteData } from '../../getChallengeRouteData';@@ -8,10 +9,6 @@ import {createCompletedSubmissionCacheKey,createInProgressSubmissionCacheKey,} from './cache-keys';-import { auth } from '@repo/auth/server';-import { AOT_CHALLENGES } from '../../aot-slugs';-import { getAllFlags } from '~/utils/feature-flags';-import { daysAfterDecemberFirst } from '~/utils/aot';interface Args {challenge: ChallengeRouteData['challenge'];@@ -23,17 +20,6 @@ export async function saveSubmission({ challenge, code, isSuccessful }: Args) {if (!session?.user) {throw new Error('Not Authorized');}-- const featureFlags = await getAllFlags();- const isAotChallenge = AOT_CHALLENGES.includes(challenge.slug);-- if (featureFlags.enableHolidayEvent && isAotChallenge) {- const [, day = '1'] = challenge.slug.split('-');- const daysPassed = daysAfterDecemberFirst();- if (parseInt(day) > daysPassed + 1) {- throw new Error('Not Available');- }- }const userId = session.user.id;const submission = await prisma.submission.create({