mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 23:12:23 +00:00
refactor(utils): move getDifficultyColor function
This commit is contained in:
parent
daa7775862
commit
6ab3e16598
@ -8,20 +8,7 @@ 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";
|
import { getDifficultyColorClass } from "@/lib/utils";
|
||||||
|
|
||||||
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({
|
||||||
@ -68,7 +55,7 @@ export default async function ProblemsetPage() {
|
|||||||
{problem.title}
|
{problem.title}
|
||||||
</Link>
|
</Link>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={`py-2.5 ${getDifficultyColor(problem.difficulty)}`}>
|
<TableCell className={`py-2.5 ${getDifficultyColorClass(problem.difficulty)}`}>
|
||||||
{problem.difficulty}
|
{problem.difficulty}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
Loading…
Reference in New Issue
Block a user