refactor(utils): move getDifficultyColor function

This commit is contained in:
cfngc4594 2025-03-30 21:04:23 +08:00
parent daa7775862
commit 6ab3e16598

View File

@ -8,20 +8,7 @@ import {
TableRow,
} from "@/components/ui/table";
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";
}
};
import { getDifficultyColorClass } from "@/lib/utils";
export default async function ProblemsetPage() {
const problems = await prisma.problem.findMany({
@ -68,7 +55,7 @@ export default async function ProblemsetPage() {
{problem.title}
</Link>
</TableCell>
<TableCell className={`py-2.5 ${getDifficultyColor(problem.difficulty)}`}>
<TableCell className={`py-2.5 ${getDifficultyColorClass(problem.difficulty)}`}>
{problem.difficulty}
</TableCell>
</TableRow>