Connect, collaborate, and grow with a community of TypeScript developers
Revert "fix: access"
bautistaaab93513bc878d
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.tsindex 6666641b..a3add10f 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts@@ -2,14 +2,11 @@import { cache } from 'react';import { prisma } from '@repo/db';-import { auth } from '@repo/auth/server';-export const getChallengeSubmissionById = cache(async (id: string) => {- const session = await auth();- return prisma.submission.findFirstOrThrow({+export const getChallengeSubmissionById = cache((id: string) => {+ return prisma.submission.findFirst({where: {id: Number(id),- userId: session?.user?.id || '',},include: {challenge: {diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsxindex 40ff359b..cb269627 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx@@ -28,7 +28,7 @@ export default async function SubmissionPage({ params: { slug } }: Props) {const submissions = await withUnstableCache({fn: getChallengeSubmissions,- args: [slug],+ args: [session?.user?.id ?? '', slug],keys: ['all-challenge-submissions'],tags: [createChallengeSubmissionCacheKey(slug)],});@@ -41,15 +41,13 @@ export default async function SubmissionPage({ params: { slug } }: Props) {}export type ChallengeSubmissions = NonNullable<Awaited<ReturnType<typeof getChallengeSubmissions>>>;-const getChallengeSubmissions = cache(async (slug: string) => {- const session = await auth();-+const getChallengeSubmissions = cache(async (userId: string, slug: string) => {const challenge = await prisma.challenge.findFirstOrThrow({where: { slug },select: { id: true },});return prisma.submission.findMany({- where: { challengeId: challenge.id, userId: session?.user?.id || '' },+ where: { challengeId: challenge.id, userId },orderBy: [{createdAt: 'desc',