mirror of
				https://github.com/massbug/judge4c.git
				synced 2025-11-04 02:35:16 +00:00 
			
		
		
		
	feat(problemset): add difficulty color mapping based on problem difficulty
This commit is contained in:
		
							parent
							
								
									9a04d83f9e
								
							
						
					
					
						commit
						ba16523c03
					
				@ -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>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user