Connect, collaborate, and grow with a community of TypeScript developers
Got Rid of some of the duplication we introduced (#150)
ggrandicf917cce3218
diff --git a/.husky/pre-commit b/.husky/pre-commitindex 370b6e68..ce933b97 100755--- a/.husky/pre-commit+++ b/.husky/pre-commit@@ -1,4 +1,4 @@#!/usr/bin/env sh. "$(dirname -- "$0")/_/husky.sh"-pnpm lint && pnpm typecheck+pnpm format && pnpm typecheck && pnpm lintdiff --git a/package.json b/package.jsonindex 5027f1f9..a0e5f016 100644--- a/package.json+++ b/package.json@@ -7,7 +7,7 @@"dev": "next dev","postinstall": "prisma generate && pnpm dl-monaco","lint": "next lint",- "reset": "prisma db push --force-reset --preview-feature",+ "reset": "prisma db push --force-reset","format": "prettier -w 'src/**/*.{ts,tsx,css,cjs,mjs,json}'","start": "next start","refresh": "pnpm reset && pnpm prisma db seed",diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsxindex a26e17a2..724e6f54 100644--- a/src/app/admin/page.tsx+++ b/src/app/admin/page.tsx@@ -1,10 +1,9 @@import { RoleTypes } from '@prisma/client';import { Lock } from 'lucide-react';-import { getServerSession } from 'next-auth';-import { authOptions } from '~/server/auth';+import { getServerAuthSession } from '~/server/auth';async function Admin() {- const session = await getServerSession(authOptions);+ const session = await getServerAuthSession();const roles = session?.user.role ?? [];const isMod = roles.includes(RoleTypes.MODERATOR);@@ -34,7 +33,7 @@ async function Admin() {}const ModerationView = async () => {- const session = await getServerSession(authOptions);+ const session = await getServerAuthSession();const roles = session?.user.role ?? [];return (diff --git a/src/app/challenge/[id]/comments/page.tsx b/src/app/challenge/[id]/comments/page.tsxindex b2e8c000..6509a66c 100644--- a/src/app/challenge/[id]/comments/page.tsx+++ b/src/app/challenge/[id]/comments/page.tsx@@ -1,7 +1,7 @@-import { getServerSession, type Session } from 'next-auth';import { notFound } from 'next/navigation';import { LeftPanel } from '~/components/challenge/left-panel';-import { prisma } from '~/server/db';+import { getChallengeRouteData } from '../getChallengeRouteData';+import { getServerAuthSession } from '../../../../server/auth';interface Props {params: {@@ -9,74 +9,13 @@ interface Props {};}-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;-export default async function CommentsPage({ params: { id } }: Props) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);- if (!challenge || typeof challenge.prompt !== 'string') {+ if (!challenge) {return notFound();}return <LeftPanel challenge={challenge} selectedTab={'comments'} />;}--async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;-}diff --git a/src/app/challenge/[id]/layout.data.tsx b/src/app/challenge/[id]/getChallengeRouteData.tssimilarity index 56%rename from src/app/challenge/[id]/layout.data.tsxrename to src/app/challenge/[id]/getChallengeRouteData.tsindex f5651e61..1c62684c 100644--- a/src/app/challenge/[id]/layout.data.tsx+++ b/src/app/challenge/[id]/getChallengeRouteData.ts@@ -1,27 +1,11 @@-'use server'-import { type Session, getServerSession } from 'next-auth';-import { ChallengeLayout } from '~/components/challenge/challenge-layout';-import { CodePanel } from '~/components/challenge/editor';-import { prisma } from '~/server/db';+'use server';+import { type Session } from 'next-auth';+import { prisma } from '../../../server/db';-export async function LayoutData({- children,- challengeId,-}: {- children: React.ReactNode;- challengeId: string;-}) {- const session = await getServerSession();- const challenge = await getChallenge(challengeId, session);- if (!challenge) return <div>loading</div>;- // if on submissions/{id} feed the overlay as right panel- // else use editor- return (- <ChallengeLayout left={children} right={<CodePanel mode="solve" challenge={challenge} />} />- );-}+export type ChallengeRouteData = NonNullable<Awaited<ReturnType<typeof getChallengeRouteData>>>;-async function getChallenge(id: string, session: Session | null) {+// TODO: Make this only get called once on the routes that need it+export async function getChallengeRouteData(id: string, session: Session | null) {const challenge = await prisma.challenge.findFirst({where: { id: +id },include: {diff --git a/src/app/challenge/[id]/layout.tsx b/src/app/challenge/[id]/layout.tsxindex f90351af..6a534e10 100644--- a/src/app/challenge/[id]/layout.tsx+++ b/src/app/challenge/[id]/layout.tsx@@ -1,9 +1,8 @@-import { getServerSession, type Session } from 'next-auth';import { ChallengeLayout } from '~/components/challenge/challenge-layout';-import { prisma } from '~/server/db';import { Wrapper } from './wrapper';+import { getChallengeRouteData } from './getChallengeRouteData';+import { getServerAuthSession } from '~/server/auth';-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;export default async function LayoutData({children,params: { id },@@ -11,67 +10,9 @@ export default async function LayoutData({children: React.ReactNode;params: { id: string };}) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);if (!challenge) return <div>loading</div>;- return <ChallengeLayout left={children} right={<Wrapper challenge={challenge} />} />;-}-async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;+ return <ChallengeLayout left={children} right={<Wrapper challenge={challenge} />} />;}diff --git a/src/app/challenge/[id]/page.tsx b/src/app/challenge/[id]/page.tsxindex 21bccb94..fbd79731 100644--- a/src/app/challenge/[id]/page.tsx+++ b/src/app/challenge/[id]/page.tsx@@ -1,7 +1,7 @@-import { getServerSession, type Session } from 'next-auth';import { notFound } from 'next/navigation';import { LeftPanel } from '~/components/challenge/left-panel';-import { prisma } from '~/server/db';+import { getChallengeRouteData } from './getChallengeRouteData';+import { getServerAuthSession } from '~/server/auth';interface Props {params: {@@ -9,13 +9,11 @@ interface Props {};}-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;-export default async function Challenges({ params: { id } }: Props) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);- if (!challenge || typeof challenge.prompt !== 'string') {+ if (!challenge) {return notFound();}@@ -23,62 +21,3 @@ export default async function Challenges({ params: { id } }: Props) {return <LeftPanel challenge={challenge} selectedTab={'description'} />;}--async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;-}diff --git a/src/app/challenge/[id]/solutions/page.tsx b/src/app/challenge/[id]/solutions/page.tsxindex d7cb68a0..2e3d353c 100644--- a/src/app/challenge/[id]/solutions/page.tsx+++ b/src/app/challenge/[id]/solutions/page.tsx@@ -1,7 +1,7 @@-import { getServerSession, type Session } from 'next-auth';import { notFound } from 'next/navigation';import { LeftPanel } from '~/components/challenge/left-panel';-import { prisma } from '~/server/db';+import { getChallengeRouteData } from '../getChallengeRouteData';+import { getServerAuthSession } from '../../../../server/auth';interface Props {params: {@@ -9,74 +9,13 @@ interface Props {};}-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;-export default async function SolutionPage({ params: { id } }: Props) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);- if (!challenge || typeof challenge.prompt !== 'string') {+ if (!challenge) {return notFound();}return <LeftPanel challenge={challenge} selectedTab={'solutions'} />;}--async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;-}diff --git a/src/app/challenge/[id]/submissions/[submissionId]/page.tsx b/src/app/challenge/[id]/submissions/[submissionId]/page.tsxindex 6665add0..eb4c4c6a 100644--- a/src/app/challenge/[id]/submissions/[submissionId]/page.tsx+++ b/src/app/challenge/[id]/submissions/[submissionId]/page.tsx@@ -1,7 +1,7 @@-import { getServerSession, type Session } from 'next-auth';import { notFound } from 'next/navigation';import { LeftPanel } from '~/components/challenge/left-panel';-import { prisma } from '~/server/db';+import { getChallengeRouteData } from '../../getChallengeRouteData';+import { getServerAuthSession } from '../../../../../server/auth';interface Props {params: {@@ -9,74 +9,13 @@ interface Props {};}-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;-export default async function SubmissionPage({ params: { id } }: Props) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);- if (!challenge || typeof challenge.prompt !== 'string') {+ if (!challenge) {return notFound();}return <LeftPanel challenge={challenge} selectedTab={'submissions'} />;}--async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;-}diff --git a/src/app/challenge/[id]/submissions/page.tsx b/src/app/challenge/[id]/submissions/page.tsxindex 6665add0..7b579e1f 100644--- a/src/app/challenge/[id]/submissions/page.tsx+++ b/src/app/challenge/[id]/submissions/page.tsx@@ -1,7 +1,7 @@-import { getServerSession, type Session } from 'next-auth';import { notFound } from 'next/navigation';import { LeftPanel } from '~/components/challenge/left-panel';-import { prisma } from '~/server/db';+import { getChallengeRouteData } from '../getChallengeRouteData';+import { getServerAuthSession } from '../../../../server/auth';interface Props {params: {@@ -9,74 +9,13 @@ interface Props {};}-export type Challenge = Awaited<ReturnType<typeof getChallenge>>;-export default async function SubmissionPage({ params: { id } }: Props) {- const session = await getServerSession();- const challenge = await getChallenge(id, session);+ const session = await getServerAuthSession();+ const challenge = await getChallengeRouteData(id, session);- if (!challenge || typeof challenge.prompt !== 'string') {+ if (!challenge) {return notFound();}return <LeftPanel challenge={challenge} selectedTab={'submissions'} />;}--async function getChallenge(id: string, session: Session | null) {- const challenge = await prisma.challenge.findFirst({- where: { id: +id },- include: {- _count: {- select: { vote: true },- },- vote: {- where: {- userId: session?.user.id,- },- },- bookmark: {- where: {- userId: session?.user.id,- },- },- solution: {- where: {- userId: session?.user.id,- },- orderBy: [- {- createdAt: 'desc',- },- ],- take: 10,- },- sharedSolution: {- orderBy: [- {- createdAt: 'desc',- },- ],- take: 5,- include: {- user: true,- _count: {- select: { vote: true, solutionComment: true },- },- },- },- comment: {- take: 10,- orderBy: [- {- createdAt: 'desc',- },- ],- include: {- user: true,- },- },- },- });-- return challenge;-}diff --git a/src/app/challenge/[id]/wrapper.tsx b/src/app/challenge/[id]/wrapper.tsxindex 5f2e9e39..ff5c46d6 100644--- a/src/app/challenge/[id]/wrapper.tsx+++ b/src/app/challenge/[id]/wrapper.tsx@@ -1,9 +1,9 @@'use client';import { useSelectedLayoutSegments } from 'next/navigation';import { CodePanel } from '~/components/challenge/editor';-import type { Challenge } from './layout';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';-export function Wrapper({ challenge }: { challenge: Challenge }) {+export function Wrapper({ challenge }: { challenge: ChallengeRouteData }) {const segments = useSelectedLayoutSegments();if (!challenge) return <div>loading</div>;console.log({ segments });diff --git a/src/components/challenge/comments.tsx b/src/components/challenge/comments.tsxindex 07bc92b6..989c64ee 100644--- a/src/components/challenge/comments.tsx+++ b/src/components/challenge/comments.tsx@@ -1,14 +1,14 @@import clsx from 'clsx';import { Button } from '~/components/ui/button';import Comment from '~/components/ui/comment';-import { type Challenge } from '~/app/challenge/[id]/page';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';import { MessageCircle, ChevronDown } from 'lucide-react';import { useState } from 'react';import { Input } from '../ui/input';import NoComments from './nocomments';interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;}const Comments = ({ challenge }: Props) => {diff --git a/src/components/challenge/description/index.tsx b/src/components/challenge/description/index.tsxindex a09a2761..c8a1d6a9 100644--- a/src/components/challenge/description/index.tsx+++ b/src/components/challenge/description/index.tsx@@ -34,10 +34,10 @@ import { toast } from '../../ui/use-toast';import { addOrRemoveBookmark } from '../bookmark.action';import { incrementOrDecrementUpvote } from '../increment.action';import { addReport } from '../report.action';-import { type Challenge } from '~/app/challenge/[id]/layout';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;}export type FormValues = {diff --git a/src/components/challenge/editor/index.tsx b/src/components/challenge/editor/index.tsxindex 8f37f3fc..a7522f67 100644--- a/src/components/challenge/editor/index.tsx+++ b/src/components/challenge/editor/index.tsx@@ -26,7 +26,7 @@ import { USER_CODE_START, USER_CODE_START_REGEX } from './constants';import { libSource } from './editor-types';import { createTwoslashInlayProvider } from './twoslash';import { VimStatusBar } from './vimMode';-import { type Challenge } from '~/app/challenge/[id]/page';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';loader.config({paths: {@@ -49,7 +49,7 @@ const LIB_URI = 'ts:filename/checking.d.ts';type Props = (| {mode: 'solve';- challenge: Pick<NonNullable<Challenge>, 'solution' | 'prompt' | 'id'>;+ challenge: Pick<ChallengeRouteData, 'solution' | 'prompt' | 'id'>;prompt?: never;}| {diff --git a/src/components/challenge/left-panel.tsx b/src/components/challenge/left-panel.tsxindex 4a81646f..899a20de 100644--- a/src/components/challenge/left-panel.tsx+++ b/src/components/challenge/left-panel.tsx@@ -5,11 +5,11 @@ import Comments from './comments';import { Description } from '~/components/challenge/description';import { Solutions } from './solutions';import { Submissions } from './submissions';-import { type Challenge } from '~/app/challenge/[id]/layout';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';import Link from 'next/link';interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;selectedTab: 'description' | 'submissions' | 'solutions' | 'comments';}diff --git a/src/components/challenge/solutions/index.tsx b/src/components/challenge/solutions/index.tsxindex 5d24be0e..9ba1f33f 100644--- a/src/components/challenge/solutions/index.tsx+++ b/src/components/challenge/solutions/index.tsx@@ -6,10 +6,10 @@ import { Button } from '~/components/ui/button';import { SolutionEditor } from './solution-editor';import { useState } from 'react';import { getRelativeTime } from '~/utils/relativeTime';-import { type Challenge } from '~/app/challenge/[id]/page';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;}export function Solutions({ challenge }: Props) {const hasSolution = challenge.solution?.length > 0;@@ -45,11 +45,7 @@ export function Solutions({ challenge }: Props) {);}-function SolutionRow({- solution,-}: {- solution: NonNullable<NonNullable<Challenge>['sharedSolution'][0]>;-}) {+function SolutionRow({ solution }: { solution: ChallengeRouteData['sharedSolution'][number] }) {return (<div className="group flex cursor-pointer flex-col gap-2 p-4 duration-300 hover:bg-neutral-100 dark:rounded-none dark:hover:bg-zinc-700/50"><div className="flex items-center justify-between">diff --git a/src/components/challenge/solutions/solution-editor.tsx b/src/components/challenge/solutions/solution-editor.tsxindex bf447edd..488da2d5 100644--- a/src/components/challenge/solutions/solution-editor.tsx+++ b/src/components/challenge/solutions/solution-editor.tsx@@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormMessage } from '~/componentimport { Input } from '~/components/ui/input';import { useToast } from '~/components/ui/use-toast';import { postSolution } from './post-solution.action';-import { type Challenge } from '~/app/challenge/[id]/layout';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';import { useSession } from 'next-auth/react';import { useTheme } from 'next-themes';import { useRouter } from 'next/navigation';@@ -34,7 +34,7 @@ const formSchema = z.object({export type FormSchema = z.infer<typeof formSchema>;interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;setOpen: (v: boolean) => void;}diff --git a/src/components/challenge/submissions.tsx b/src/components/challenge/submissions.tsxindex 58bbdd53..e4a4f155 100644--- a/src/components/challenge/submissions.tsx+++ b/src/components/challenge/submissions.tsx@@ -1,7 +1,7 @@'use client';import type { Solution } from '@prisma/client';-import { type Challenge } from '~/app/challenge/[id]/layout';+import { type ChallengeRouteData } from '~/app/challenge/[id]/getChallengeRouteData';import { getRelativeTime } from '~/utils/relativeTime';import clsx from 'clsx';import {@@ -15,7 +15,7 @@ import {import { useMemo, useState } from 'react';interface Props {- challenge: NonNullable<Challenge>;+ challenge: ChallengeRouteData;}type Status = 'all' | 'accepted' | 'rejected';diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsxindex 1bebdc87..11a79429 100644--- a/src/components/explore/explore-card.tsx+++ b/src/components/explore/explore-card.tsx@@ -2,15 +2,15 @@import { ThumbsUp } from 'lucide-react';-import { type Challenge } from '.';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';import { DifficultyBadge } from './difficulty-badge';import { Markdown } from '../ui/markdown';import { getRelativeTime } from '~/utils/relativeTime';+import { type ExploreChallengeData } from '.';interface Props {challenge: Pick<- Awaited<Challenge>[0],+ ExploreChallengeData[number],'difficulty' | 'name' | 'shortDescription' | '_count' | 'updatedAt'>;}diff --git a/src/components/explore/index.tsx b/src/components/explore/index.tsxindex e21e8c2c..bc05fcbf 100644--- a/src/components/explore/index.tsx+++ b/src/components/explore/index.tsx@@ -3,7 +3,9 @@ import { ExploreSection } from './section';import { Suspense } from 'react';import { ExploreSectionSkeleton } from './section-skeleton';-export function Explore() {+export async function Explore() {+ const data = await getExploreChallengeData();+return (<div className="container flex h-full flex-col"><section className="mb-8 flex max-w-[69ch] flex-col items-start gap-2">@@ -21,14 +23,14 @@ export function Explore() {</section><Suspense fallback={<ExploreSectionSkeleton />}>- <ExploreSection data={getChallenge} />+ <ExploreSection data={data} /></Suspense></div>);}-export type Challenge = ReturnType<typeof getChallenge>;-async function getChallenge() {+export type ExploreChallengeData = Awaited<ReturnType<typeof getExploreChallengeData>>;+async function getExploreChallengeData() {return prisma.challenge.findMany({include: {_count: {diff --git a/src/components/explore/section.tsx b/src/components/explore/section.tsxindex f74103fd..260c595a 100644--- a/src/components/explore/section.tsx+++ b/src/components/explore/section.tsx@@ -1,17 +1,16 @@import Link from 'next/link';-import type { Challenge } from '.';+import type { ExploreChallengeData } from '.';import { ExploreCard } from './explore-card';interface Props {- data(): Challenge;+ data: ExploreChallengeData;}-export async function ExploreSection({ data }: Props) {- const challenges = await data();+export function ExploreSection({ data }: Props) {return (<div><div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">- {challenges.map((challenge) => (+ {data.map((challenge) => (<LinkclassName="group focus:outline-none"href={`/challenge/${challenge.id}`}diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsxindex c5d335bf..48940155 100644--- a/src/components/ui/navigation.tsx+++ b/src/components/ui/navigation.tsx@@ -127,8 +127,9 @@ export function Navigation() {return (<header className="w-full"><nav- className={`flex h-14 items-center ${pathname.includes('/challenge') || pathname.includes('/create') ? 'px-4' : 'container'- }`}+ className={`flex h-14 items-center ${+ pathname.includes('/challenge') || pathname.includes('/create') ? 'px-4' : 'container'+ }`}><div className="flex w-full items-center justify-between"><div className="relative flex">diff --git a/src/server/api/trpc.ts b/src/server/api/trpc.tsindex da8548e5..6ad3ee45 100644--- a/src/server/api/trpc.ts+++ b/src/server/api/trpc.ts@@ -9,9 +9,10 @@import { initTRPC, TRPCError } from '@trpc/server';import { type CreateNextContextOptions } from '@trpc/server/adapters/next';+import { getServerSession } from 'next-auth';import superjson from 'superjson';import { ZodError } from 'zod';-import { getServerAuthSession } from '~/server/auth';+import { authOptions } from '~/server/auth';import { prisma } from '~/server/db';/**@@ -31,8 +32,8 @@ import { prisma } from '~/server/db';export const createTRPCContext = async (opts: CreateNextContextOptions) => {const { req, res } = opts;- // Get the session from the server using the getServerSession wrapper function- const session = await getServerAuthSession({ req, res });+ // Get the session from the server using the getServerAuthSession wrapper function+ const session = await getServerSession(req, res, authOptions);return {session,diff --git a/src/server/auth.ts b/src/server/auth.tsindex 6f699e2e..077db316 100644--- a/src/server/auth.ts+++ b/src/server/auth.ts@@ -1,6 +1,5 @@import { PrismaAdapter } from '@next-auth/prisma-adapter';import type { Role, RoleTypes } from '@prisma/client';-import { type GetServerSidePropsContext } from 'next';import { getServerSession, type DefaultSession, type NextAuthOptions } from 'next-auth';import GitHubProvider from 'next-auth/providers/github';import { env } from '~/env.mjs';@@ -94,9 +93,6 @@ export const authOptions: NextAuthOptions = {** @see https://next-auth.js.org/configuration/nextjs*/-export const getServerAuthSession = (ctx: {- req: GetServerSidePropsContext['req'];- res: GetServerSidePropsContext['res'];-}) => {- return getServerSession(ctx.req, ctx.res, authOptions);+export const getServerAuthSession = () => {+ return getServerSession(authOptions);};