mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +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 ProblemDescriptionFooter from "@/features/playground/problem/description/footer";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
interface ProblemDescriptionLayoutProps {
|
interface ProblemDescriptionLayoutProps {
|
||||||
|
params: Promise<{ id: string }>;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ProblemDescriptionLayout({
|
export default async function ProblemDescriptionLayout({
|
||||||
|
params,
|
||||||
children,
|
children,
|
||||||
}: ProblemDescriptionLayoutProps) {
|
}: ProblemDescriptionLayoutProps) {
|
||||||
|
const { id } = await params;
|
||||||
|
|
||||||
|
const problem = await prisma.problem.findUnique({
|
||||||
|
where: { id: parseInt(id) },
|
||||||
|
select: {
|
||||||
|
title: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = problem?.title ?? "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col">
|
<div className="h-full flex flex-col">
|
||||||
<div className="flex-1">{children}</div>
|
<div className="flex-1">{children}</div>
|
||||||
<ProblemDescriptionFooter />
|
<ProblemDescriptionFooter title={title} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
interface ProblemDescriptionFooterProps {
|
interface ProblemDescriptionFooterProps {
|
||||||
|
title: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ProblemDescriptionFooter({
|
export default function ProblemDescriptionFooter({
|
||||||
|
title,
|
||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: ProblemDescriptionFooterProps) {
|
}: 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)}
|
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">
|
<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>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user