Connect, collaborate, and grow with a community of TypeScript developers
refresh challenge on submission (#80)
bautistaaaf93f186e9cdb
diff --git a/src/components/challenge/editor/index.tsx b/src/components/challenge/editor/index.tsxindex 5bf0ca65..cdf36597 100644--- a/src/components/challenge/editor/index.tsx+++ b/src/components/challenge/editor/index.tsx@@ -6,6 +6,7 @@ import { Loader2, Settings } from 'lucide-react';import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';import { useSession } from 'next-auth/react';import { useTheme } from 'next-themes';+import { useRouter } from 'next/navigation';import { useMemo, useRef, useState } from 'react';import { Button } from '~/components/ui/button';import {@@ -47,6 +48,7 @@ interface Props {const libCache = new Set<string>();export const CodePanel = ({ challenge }: Props) => {+ const router = useRouter();const { toast } = useToast();const { theme } = useTheme();const { data: session } = useSession();@@ -102,6 +104,7 @@ export const CodePanel = ({ challenge }: Props) => {session?.user?.id as string,JSON.stringify(solution) ?? '',);+ router.refresh();toast({variant: 'success',title: 'Good job!',diff --git a/src/components/challenge/index.tsx b/src/components/challenge/index.tsxindex c3a969e5..0850dc2f 100644--- a/src/components/challenge/index.tsx+++ b/src/components/challenge/index.tsx@@ -12,8 +12,9 @@ export type Challenge = Awaited<ReturnType<typeof getChallenge>>;export async function Challenge({ id }: Props) {const session = await getServerSession();const challenge = await getChallenge(id, session);+if (!challenge || typeof challenge.prompt !== 'string') {- notFound();+ return notFound();}return <InnerIndex challenge={challenge} />;