|
1 | 1 | import { Link } from 'react-router-dom'; |
2 | | -import { Code2, ListChecks, PenLine, CheckCircle2, Star } from 'lucide-react'; |
| 2 | +import { Code2, ListChecks, PenLine, CheckCircle2, Star, AlertCircle } from 'lucide-react'; |
3 | 3 | import { useBookmarks } from '../context/BookmarkContext'; |
4 | 4 | import type { Problem } from '../types'; |
5 | 5 |
|
@@ -41,20 +41,27 @@ export default function ProblemCard({ problem }: { problem: Problem }) { |
41 | 41 | const ratio = problem.submission_count > 0 |
42 | 42 | ? Math.round((problem.accepted_count / problem.submission_count) * 100) |
43 | 43 | : 0; |
| 44 | + const userStatus = problem.user_status || (problem.user_passed ? 'accepted' : null); |
44 | 45 |
|
45 | 46 | return ( |
46 | 47 | <Link |
47 | 48 | to={`/problems/${problem.id}`} |
48 | | - className={`card flex flex-col gap-4 hover:border-primary-500/50 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-primary-500/5 transition-all duration-200 group${problem.user_passed ? ' border-l-emerald-500' : ''}`} |
| 49 | + className={`card flex flex-col gap-4 hover:border-primary-500/50 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-primary-500/5 transition-all duration-150 group${userStatus === 'accepted' ? ' border-l-emerald-500' : userStatus === 'attempted' ? ' border-l-yellow-500' : ''}`} |
49 | 50 | > |
50 | 51 | <div className="flex items-start justify-between gap-3"> |
51 | 52 | <div className="flex items-center gap-2.5 min-w-0"> |
52 | | - {problem.user_passed && ( |
| 53 | + {userStatus === 'accepted' && ( |
53 | 54 | <span className="inline-flex items-center gap-1 px-2 py-0.5 bg-emerald-500/15 text-emerald-400 text-xs rounded-full border border-emerald-500/30 flex-shrink-0"> |
54 | 55 | <CheckCircle2 className="w-3.5 h-3.5" /> |
55 | 56 | 已通过 |
56 | 57 | </span> |
57 | 58 | )} |
| 59 | + {userStatus === 'attempted' && ( |
| 60 | + <span className="inline-flex items-center gap-1 px-2 py-0.5 bg-yellow-500/15 text-yellow-400 text-xs rounded-full border border-yellow-500/30 flex-shrink-0"> |
| 61 | + <AlertCircle className="w-3.5 h-3.5" /> |
| 62 | + 已尝试 |
| 63 | + </span> |
| 64 | + )} |
58 | 65 | <h3 className="text-lg font-semibold text-white truncate group-hover:text-primary-400 transition-colors"> |
59 | 66 | {problem.title} |
60 | 67 | </h3> |
|
0 commit comments