Connect, collaborate, and grow with a community of TypeScript developers
feat: stub out aot 2023 (#1128)
bautistaaa00f0f0280041
diff --git a/apps/admin/src/components/navigation.tsx b/apps/admin/src/components/navigation.tsxindex c2892c9f..3601fb24 100644--- a/apps/admin/src/components/navigation.tsx+++ b/apps/admin/src/components/navigation.tsx@@ -1,7 +1,6 @@'use client';import { signIn, signOut, useSession } from '@repo/auth/react';-import { RoleTypes } from '@repo/db/types';import { Button } from '@repo/ui/components/button';import {DropdownMenu,@@ -88,10 +87,6 @@ function LoginButton() {const [loading, setLoading] = useState(false);const { data: session, status } = useSession();- const isAdmin = session?.user.role.includes(RoleTypes.ADMIN);- const isMod = session?.user.role.includes(RoleTypes.MODERATOR);- const isAdminOrMod = isAdmin || isMod;-// NOTE: 1. loading == true -> 2. signIn() -> 3. session status == 'loading' (loading == false)const handleSignIn = async () => {try {diff --git a/apps/web/src/app/[locale]/aot-2023/_components/card-grid.tsx b/apps/web/src/app/[locale]/aot-2023/_components/card-grid.tsxnew file mode 100644index 00000000..53eb6369--- /dev/null+++ b/apps/web/src/app/[locale]/aot-2023/_components/card-grid.tsx@@ -0,0 +1,56 @@+import { prisma } from '@repo/db';+import { ChallengeCard } from './challenge-card';++const slugs = [+ 'hello-world',+ 'pick',+ 'awaited',+ 'readonly',+ 'exclude',+ 'parameters',+ 'omit',+ 'pop',+ 'trim-left',+ 'get-return-type',+ 'permutation',+ 'currying-1',+];++export async function CardGrid() {+ const challenges = await getChallenges();+ const challengesToReveal = revealItems(challenges);++ return (+ <div className="container">+ <section className="w-[calc(100% + 8rem)] grid grid-cols-1 gap-4 sm:px-8 md:-mx-16 md:grid-cols-2 md:px-0 lg:mx-0 lg:w-full xl:grid-cols-3 2xl:gap-8">+ {challengesToReveal?.map((challenge, i) => {+ return <ChallengeCard key={i} challenge={challenge} />;+ })}+ </section>+ </div>+ );+}++export type Challenges = NonNullable<Awaited<ReturnType<typeof getChallenges>>>;+async function getChallenges() {+ return prisma.challenge.findMany({+ where: {+ slug: {+ in: slugs,+ },+ },+ });+}++const MS_PER_DAY = 24 * 60 * 60 * 1000;+function revealItems(items: Challenges) {+ const startDate: Date = new Date('2023-12-14');+ const today: Date = new Date();++ const daysPassed = Math.floor((today.getTime() - startDate.getTime()) / MS_PER_DAY) - 1;++ return items.map((item, index) => {+ const isPastOrCurrentDay = index <= daysPassed;+ return { ...item, isRevealed: isPastOrCurrentDay };+ });+}diff --git a/apps/web/src/app/[locale]/aot-2023/_components/challenge-card.tsx b/apps/web/src/app/[locale]/aot-2023/_components/challenge-card.tsxnew file mode 100644index 00000000..48e2dca7--- /dev/null+++ b/apps/web/src/app/[locale]/aot-2023/_components/challenge-card.tsx@@ -0,0 +1,19 @@+import { Card, CardContent } from '@repo/ui/components/card';+import type { Challenges } from './card-grid';++interface Prop {+ challenge: Challenges[0] & { isRevealed: boolean };+}+export function ChallengeCard({ challenge }: Prop) {+ return (+ <Card className="dark:group-hover:border-border relative overflow-hidden duration-300 group-hover:border-neutral-400 group-hover:shadow-xl group-focus:border-neutral-500 dark:group-hover:shadow dark:group-hover:shadow-neutral-400/70">+ <CardContent className="relative z-10 flex flex-col items-center gap-5 p-8">+ <div className="text-center font-semibold capitalize tracking-wide">{challenge.name}</div>+ <div className="text-muted-foreground line-clamp-3 text-center text-sm tracking-wide">+ something goes here maybe+ </div>+ {challenge.isRevealed ? <div>REVEALED!</div> : <div>NOT REVEALED!</div>}+ </CardContent>+ </Card>+ );+}diff --git a/apps/web/src/app/[locale]/aot-2023/_components/index.tsx b/apps/web/src/app/[locale]/aot-2023/_components/index.tsxnew file mode 100644index 00000000..d76a0b41--- /dev/null+++ b/apps/web/src/app/[locale]/aot-2023/_components/index.tsx@@ -0,0 +1,26 @@+import { notFound } from 'next/navigation';+import { getAllFlags } from '~/utils/feature-flags';+import { CardGrid } from './card-grid';++export async function AotLandingPage() {+ const featureFlags = await getAllFlags();+ if (!featureFlags.enableHolidayEvent) return notFound();++ return (+ <div className="flex flex-col gap-5 pb-8 md:gap-10 md:py-5">+ <div className="container">+ <p className="max-w-[69ch] text-lg leading-7 text-neutral-600 dark:text-white/50 sm:px-8 md:px-0">+ Amidst the{' '}+ <span className="font-semibold text-red-600 dark:text-red-400">+ 12 Days of TypeScript+ </span>+ , my coding workshop turned into a festive frenzy! Bugs were jingled away, interfaces+ decked with digital tinsel, and puzzling challenges twinkled like digital ornaments! Every+ win felt like unwrapping a virtual gift, turning those Twelve Days into a tech+ wonderland—a merry, coding celebration of joy and cheer!+ </p>+ </div>+ <CardGrid />+ </div>+ );+}diff --git a/apps/web/src/app/[locale]/aot-2023/page.tsx b/apps/web/src/app/[locale]/aot-2023/page.tsxnew file mode 100644index 00000000..970c5f39--- /dev/null+++ b/apps/web/src/app/[locale]/aot-2023/page.tsx@@ -0,0 +1,11 @@+import type { Metadata } from 'next';+import { buildMetaForDefault } from '~/app/metadata';++export async function generateMetadata(): Promise<Metadata> {+ return buildMetaForDefault({+ title: 'Advent of Typescript 2023 | TypeHero',+ description: 'Advent of Typescript 2023',+ });+}++export { AotLandingPage as default } from './_components';diff --git a/apps/web/src/components/Navigation/index.tsx b/apps/web/src/components/Navigation/index.tsxindex 8474baa1..a6553e19 100644--- a/apps/web/src/components/Navigation/index.tsx+++ b/apps/web/src/components/Navigation/index.tsx@@ -67,6 +67,9 @@ export async function Navigation() {</Link>{featureFlags?.enableExplore ? <NavLink title={t('explore')} href="/explore" /> : null}{featureFlags?.enableTracks ? <NavLink title={t('tracks')} href="/tracks" /> : null}+ {featureFlags?.enableHolidayEvent ? (+ <NavLink title={t('advent')} href="/aot-2023" />+ ) : null}</div><div className="flex"><div className="flex items-center justify-end gap-2">diff --git a/apps/web/src/locales/en.ts b/apps/web/src/locales/en.tsindex 45a2140b..ff2e076e 100644--- a/apps/web/src/locales/en.ts+++ b/apps/web/src/locales/en.ts@@ -5,4 +5,5 @@ export default {'404.message': 'Page not found, sus','navigation.explore': 'Explore','navigation.tracks': 'Tracks',+ 'navigation.advent': 'Advent of TypeScript',} as const;diff --git a/challenges/aot/2023/blank/metadata.json b/challenges/aot/2023/blank/metadata.jsonnew file mode 100644index 00000000..cf5eb6ea--- /dev/null+++ b/challenges/aot/2023/blank/metadata.json@@ -0,0 +1,8 @@+{+ "id": "lower-snake-case",+ "label": "Lower Snake Case",+ "description": "Try to keep it to one shortish sentence.",+ "difficulty": "beginner",+ "prerequisites": [],+ "author": "your-github-user-id"+}diff --git a/challenges/aot/2023/blank/prompt.md b/challenges/aot/2023/blank/prompt.mdnew file mode 100644index 00000000..f636ea4b--- /dev/null+++ b/challenges/aot/2023/blank/prompt.md@@ -0,0 +1,11 @@+## What Problem XYZ Solves++Explain: why this is important or useful knowledge++## How To Use XYZ++What's the API of the type? What generics and in what order?++## Solving This Challenge++Short and to-the-point. Should be _possible_ to skip everything above and just read this.diff --git a/challenges/aot/2023/blank/solutions/1.ts b/challenges/aot/2023/blank/solutions/1.tsnew file mode 100644index 00000000..e69de29bdiff --git a/challenges/aot/2023/blank/tests.ts b/challenges/aot/2023/blank/tests.tsnew file mode 100644index 00000000..78123de9--- /dev/null+++ b/challenges/aot/2023/blank/tests.ts@@ -0,0 +1 @@+import { Expect, Equal } from 'type-testing';diff --git a/challenges/aot/2023/blank/tsconfig.json b/challenges/aot/2023/blank/tsconfig.jsonnew file mode 100644index 00000000..d8de5a26--- /dev/null+++ b/challenges/aot/2023/blank/tsconfig.json@@ -0,0 +1,7 @@+{+ "compilerOptions": {+ "strict": true,+ "exactOptionalPropertyTypes": true,+ "noUncheckedIndexedAccess": true+ }+}diff --git a/challenges/aot/2023/blank/user.ts b/challenges/aot/2023/blank/user.tsnew file mode 100644index 00000000..5c69415c--- /dev/null+++ b/challenges/aot/2023/blank/user.ts@@ -0,0 +1 @@+type XYZ = unknown;