diff --git a/src/app/(app)/problems/[id]/layout.tsx b/src/app/(app)/problems/[id]/layout.tsx index 304f5b9..8ed15e9 100644 --- a/src/app/(app)/problems/[id]/layout.tsx +++ b/src/app/(app)/problems/[id]/layout.tsx @@ -1,90 +1,25 @@ -import prisma from "@/lib/prisma"; import { notFound } from "next/navigation"; -import { getUserLocale } from "@/i18n/locale"; -import ProblemPage from "@/app/(app)/problems/[id]/page"; -import { ProblemStoreProvider } from "@/providers/problem-store-provider"; -import { PlaygroundHeader } from "@/components/features/playground/header"; +import { ProblemHeader } from "@/features/problems/components/problem-header"; -interface ProblemProps { +interface ProblemLayoutProps { + children: React.ReactNode; params: Promise<{ id: string }>; - Description: React.ReactNode; - Solutions: React.ReactNode; - Submissions: React.ReactNode; - Details: React.ReactNode; - Code: React.ReactNode; - Testcase: React.ReactNode; - Bot: React.ReactNode; } export default async function ProblemLayout({ + children, params, - Description, - Solutions, - Submissions, - Details, - Code, - Testcase, - Bot, -}: ProblemProps) { +}: ProblemLayoutProps) { const { id } = await params; if (!id) { return notFound(); } - const [ - problem, - editorLanguageConfigs, - languageServerConfigs, - submissions, - ] = await Promise.all([ - prisma.problem.findUnique({ - where: { id }, - include: { - templates: true, - testcases: { - include: { - data: true, - }, - }, - }, - }), - prisma.editorLanguageConfig.findMany(), - prisma.languageServerConfig.findMany(), - prisma.submission.findMany({ - where: { problemId: id }, - }), - ]); - - if (!problem) { - return notFound(); - } - - const locale = await getUserLocale(); - return (
- - -
- -
-
+ + {children}
); } diff --git a/src/app/(app)/problemset/layout.tsx b/src/app/(app)/problemset/layout.tsx index b3c2b26..efed448 100644 --- a/src/app/(app)/problemset/layout.tsx +++ b/src/app/(app)/problemset/layout.tsx @@ -1,5 +1,4 @@ -import { Banner } from "@/components/banner"; -import { AvatarButton } from "@/components/avatar-button"; +import { ProblemsetHeader } from "@/features/problemset/components/problemset-header"; interface ProblemsetLayoutProps { children: React.ReactNode; @@ -7,14 +6,9 @@ interface ProblemsetLayoutProps { export default function ProblemsetLayout({ children }: ProblemsetLayoutProps) { return ( -
- -
- -
-
- {children} -
+
+ + {children}
); } diff --git a/src/components/features/playground/header.tsx b/src/components/features/playground/header.tsx deleted file mode 100644 index bd730a1..0000000 --- a/src/components/features/playground/header.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { cn } from "@/lib/utils"; -import { auth } from "@/lib/auth"; -import BackButton from "@/components/back-button"; -import { RunCodeButton } from "@/components/run-code"; -import { AvatarButton } from "@/components/avatar-button"; -import BotVisibilityToggle from "@/components/bot-visibility-toggle"; - -interface PlaygroundHeaderProps { - className?: string; -} - -export async function PlaygroundHeader({ - className, - ...props -}: PlaygroundHeaderProps) { - const session = await auth(); - - return ( -
- -
-
-
- -
-
-
-
- ); -} diff --git a/src/components/back-button.tsx b/src/features/problems/components/navigate-back-button.tsx similarity index 76% rename from src/components/back-button.tsx rename to src/features/problems/components/navigate-back-button.tsx index d894fd0..a6e144f 100644 --- a/src/components/back-button.tsx +++ b/src/features/problems/components/navigate-back-button.tsx @@ -1,20 +1,21 @@ import Link from "next/link"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; import { useTranslations } from "next-intl"; import { ArrowLeftIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; -interface BackButtonProps { +interface NavigateBackButtonProps { href: string; className?: string; } -export default function BackButton({ - href, - className, - ...props -}: BackButtonProps) { +const NavigateBackButton = ({ href, className }: NavigateBackButtonProps) => { const t = useTranslations(); return ( @@ -25,7 +26,6 @@ export default function BackButton({ variant="ghost" className={cn("h-8 w-auto p-2", className)} asChild - {...props} >