diff --git a/src/app/(app)/problems/[id]/@Details/page.tsx b/src/app/(app)/problems/[id]/@Details/page.tsx new file mode 100644 index 0000000..dbd8666 --- /dev/null +++ b/src/app/(app)/problems/[id]/@Details/page.tsx @@ -0,0 +1,109 @@ +"use client"; + +import { cn } from "@/lib/utils"; +import { ArrowLeftIcon } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { useProblem } from "@/hooks/use-problem"; +import MdxPreview from "@/components/mdx-preview"; +import { useDockviewStore } from "@/stores/dockview"; +import { Separator } from "@/components/ui/separator"; +import { getStatusColorClass, statusMap } from "@/lib/status"; +import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import { formatDistanceToNow, isBefore, subDays, format } from "date-fns"; + +export default function DetailsPage() { + const { api, submission } = useDockviewStore(); + const { editorLanguageConfigs, problemId } = useProblem(); + + if (!api || !problemId || !submission?.id) return null; + + if (problemId !== submission.problemId) { + const detailsPanel = api.getPanel("Details"); + if (detailsPanel) { + api.removePanel(detailsPanel); + } + } + + const createdAt = new Date(submission.createdAt); + const submittedDisplay = isBefore(createdAt, subDays(new Date(), 1)) + ? format(createdAt, "yyyy-MM-dd") + : formatDistanceToNow(createdAt, { addSuffix: true }); + + const source = `\`\`\`${submission?.language}\n${submission?.code}\n\`\`\``; + + const handleClick = () => { + if (!api) return; + const submissionsPanel = api.getPanel("Submissions"); + submissionsPanel?.api.setActive(); + const detailsPanel = api.getPanel("Details"); + if (detailsPanel) { + api.removePanel(detailsPanel); + } + } + + return ( +
+
+ +
+
+
+ +
+
+
+
+

+ + {statusMap.get(submission.status)?.message} + +

+
+ Submitted on + + {submittedDisplay} + +
+
+
+
+ +
+
+
+ Code + + + { + editorLanguageConfigs.find( + (config) => config.language === submission.language + )?.label + } + +
+
+ +
+
+ +
+
+
+
+ ); +} diff --git a/src/app/(app)/problems/[id]/layout.tsx b/src/app/(app)/problems/[id]/layout.tsx index f19e86f..2cfb80c 100644 --- a/src/app/(app)/problems/[id]/layout.tsx +++ b/src/app/(app)/problems/[id]/layout.tsx @@ -9,6 +9,7 @@ interface ProblemProps { Description: React.ReactNode; Solutions: React.ReactNode; Submissions: React.ReactNode; + Details: React.ReactNode; Code: React.ReactNode; Testcase: React.ReactNode; TestResult: React.ReactNode; @@ -20,6 +21,7 @@ export default async function ProblemLayout({ Description, Solutions, Submissions, + Details, Code, Testcase, TestResult, @@ -74,6 +76,7 @@ export default async function ProblemLayout({ Description={Description} Solutions={Solutions} Submissions={Submissions} + Details={Details} Code={Code} Testcase={Testcase} TestResult={TestResult} diff --git a/src/app/(app)/problems/[id]/page.tsx b/src/app/(app)/problems/[id]/page.tsx index ecb4a51..9bacf17 100644 --- a/src/app/(app)/problems/[id]/page.tsx +++ b/src/app/(app)/problems/[id]/page.tsx @@ -16,6 +16,7 @@ interface ProblemPageProps { Description: React.ReactNode; Solutions: React.ReactNode; Submissions: React.ReactNode; + Details: React.ReactNode; Code: React.ReactNode; Testcase: React.ReactNode; TestResult: React.ReactNode; @@ -26,6 +27,7 @@ export default function ProblemPage({ Description, Solutions, Submissions, + Details, Code, Testcase, TestResult, @@ -77,6 +79,17 @@ export default function ProblemPage({ }, inactive: true, }, + { + id: "Details", + component: "Details", + tabComponent: "Details", + title: "Details", + params: { + icon: CircleCheckBigIcon, + content: Details, + autoAdd: false, + }, + }, { id: "Code", component: "Code",