mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(problem-description): add dynamic title to footer and fetch problem title
This commit is contained in:
parent
ef753dd6c8
commit
163dc4b57c
@ -1,16 +1,30 @@
|
||||
import ProblemDescriptionFooter from "@/features/playground/problem/description/footer";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
interface ProblemDescriptionLayoutProps {
|
||||
params: Promise<{ id: string }>;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function ProblemDescriptionLayout({
|
||||
export default async function ProblemDescriptionLayout({
|
||||
params,
|
||||
children,
|
||||
}: ProblemDescriptionLayoutProps) {
|
||||
const { id } = await params;
|
||||
|
||||
const problem = await prisma.problem.findUnique({
|
||||
where: { id: parseInt(id) },
|
||||
select: {
|
||||
title: true,
|
||||
}
|
||||
});
|
||||
|
||||
const title = problem?.title ?? "";
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
<div className="flex-1">{children}</div>
|
||||
<ProblemDescriptionFooter />
|
||||
<ProblemDescriptionFooter title={title} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface ProblemDescriptionFooterProps {
|
||||
title: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default function ProblemDescriptionFooter({
|
||||
title,
|
||||
className,
|
||||
...props
|
||||
}: ProblemDescriptionFooterProps) {
|
||||
@ -14,7 +16,7 @@ export default function ProblemDescriptionFooter({
|
||||
className={cn("h-9 flex flex-none items-center bg-muted px-3 py-2", className)}
|
||||
>
|
||||
<div className="w-full flex items-center justify-center">
|
||||
<span className="truncate">Description of Two Sum</span>
|
||||
<span className="truncate">Description of {title}</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user