feat(problemset): add difficulty color mapping based on problem difficulty

This commit is contained in:
cfngc4594 2025-03-07 16:34:51 +08:00
parent 9a04d83f9e
commit ba16523c03

View File

@ -8,6 +8,20 @@ import {
TableRow, TableRow,
} from "@/components/ui/table"; } from "@/components/ui/table";
import prisma from "@/lib/prisma"; import prisma from "@/lib/prisma";
import { Difficulty } from "@prisma/client";
const getDifficultyColor = (difficulty: Difficulty) => {
switch (difficulty) {
case "EASY":
return "text-green-500";
case "MEDIUM":
return "text-yellow-500";
case "HARD":
return "text-red-500";
default:
return "text-gray-500";
}
};
export default async function ProblemsetPage() { export default async function ProblemsetPage() {
const problems = await prisma.problem.findMany({ const problems = await prisma.problem.findMany({
@ -46,7 +60,9 @@ export default async function ProblemsetPage() {
{problem.title} {problem.title}
</Link> </Link>
</TableCell> </TableCell>
<TableCell className="py-2.5"> <TableCell
className={`py-2.5 ${getDifficultyColor(problem.difficulty)}`}
>
{problem.difficulty} {problem.difficulty}
</TableCell> </TableCell>
</TableRow> </TableRow>