|
| 1 | +import { BookOpen, User, Calendar, Clock } from "lucide-react"; |
| 2 | +import BadgeLeader from "~/components/BadgeLeader"; |
| 3 | +import { useQuery } from "@tanstack/react-query"; |
| 4 | +import TeamApi from "~/api-requests/team.requests"; |
| 5 | +import Loading from "~/components/Loading"; |
| 6 | + |
| 7 | +const TeamPage = () => { |
| 8 | + const { data: teams, isLoading } = useQuery({ |
| 9 | + queryKey: ["teams"], |
| 10 | + queryFn: async () => { |
| 11 | + const res = await TeamApi.getAllTeams(); |
| 12 | + return res.result; |
| 13 | + }, |
| 14 | + }); |
| 15 | + if (isLoading) <Loading />; |
| 16 | + |
| 17 | + return ( |
| 18 | + <> |
| 19 | + <section className="mb-6 sm:mb-8"> |
| 20 | + <h1 className="text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl">Danh sách các nhóm</h1> |
| 21 | + <p className="mt-2 text-sm text-gray-600"> |
| 22 | + Xem thông tin các nhóm tham gia Challenge vòng 3. Tổng cộng:{" "} |
| 23 | + <span className="text-primary font-semibold">{teams?.length || 0}</span> nhóm |
| 24 | + </p> |
| 25 | + </section> |
| 26 | + |
| 27 | + <section className="space-y-8"> |
| 28 | + {teams?.map((team, index) => ( |
| 29 | + <> |
| 30 | + {index > 0 && <div className="border-t border-gray-200/50" />} |
| 31 | + <div key={team.id} className="grid grid-cols-1 gap-4 lg:grid-cols-12 lg:gap-2"> |
| 32 | + <div className="col-span-1 lg:col-span-8"> |
| 33 | + <div className="overflow-hidden rounded-lg border border-gray-200/70 bg-white shadow-xs transition-all"> |
| 34 | + <div className="border-b border-gray-200/70 bg-gradient-to-r from-gray-50/80 to-white px-5 py-4 sm:px-6 sm:py-5"> |
| 35 | + <h2 className="text-base font-semibold tracking-tight text-gray-900 sm:text-lg"> |
| 36 | + [NHÓM <span className="text-primary font-bold">{team?.group}</span>] -{" "} |
| 37 | + {team?.name ? ( |
| 38 | + <span className="text-primary font-bold">{team.name}</span> |
| 39 | + ) : ( |
| 40 | + <span className="text-red-500">Chưa đặt tên nhóm</span> |
| 41 | + )} |
| 42 | + </h2> |
| 43 | + </div> |
| 44 | + <div className="overflow-auto"> |
| 45 | + <table className="w-full"> |
| 46 | + <thead className="bg-gray-50/50"> |
| 47 | + <tr> |
| 48 | + <th className="px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5"> |
| 49 | + STT |
| 50 | + </th> |
| 51 | + <th className="px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5"> |
| 52 | + Họ và tên |
| 53 | + </th> |
| 54 | + <th className="px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5"> |
| 55 | + MSSV |
| 56 | + </th> |
| 57 | + <th className="px-4 py-3 text-left text-xs font-semibold tracking-wide text-gray-600 uppercase sm:px-6 sm:py-3.5"> |
| 58 | + Ngành |
| 59 | + </th> |
| 60 | + </tr> |
| 61 | + </thead> |
| 62 | + <tbody className="divide-y divide-gray-200/60 bg-white"> |
| 63 | + {team.candidates?.map((candidate, index) => { |
| 64 | + const isLeader = candidate.id === team.leaderId; |
| 65 | + return ( |
| 66 | + <tr |
| 67 | + key={candidate.id} |
| 68 | + className="transition-colors hover:bg-gray-50/50" |
| 69 | + > |
| 70 | + <td className="px-4 py-3.5 text-sm font-medium whitespace-nowrap text-gray-900 sm:px-6 sm:py-4"> |
| 71 | + {index + 1} |
| 72 | + </td> |
| 73 | + <td |
| 74 | + className={`${isLeader ? "font-semibold text-gray-900" : "text-gray-700"} px-4 py-3.5 text-sm whitespace-nowrap sm:px-6 sm:py-4`} |
| 75 | + > |
| 76 | + <div className="flex items-center gap-2"> |
| 77 | + {candidate.user.fullName} |
| 78 | + {isLeader && <BadgeLeader />} |
| 79 | + </div> |
| 80 | + </td> |
| 81 | + <td className="px-4 py-3.5 text-sm whitespace-nowrap text-gray-600 sm:px-6 sm:py-4"> |
| 82 | + <p className="text-sm font-semibold text-gray-900"> |
| 83 | + {candidate.studentCode} |
| 84 | + </p> |
| 85 | + </td> |
| 86 | + <td className="px-4 py-3.5 text-sm text-gray-600 sm:px-6 sm:py-4"> |
| 87 | + <p className="text-sm text-gray-900"> |
| 88 | + {candidate.major} |
| 89 | + </p> |
| 90 | + </td> |
| 91 | + </tr> |
| 92 | + ); |
| 93 | + })} |
| 94 | + </tbody> |
| 95 | + </table> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + </div> |
| 99 | + |
| 100 | + <div className="col-span-1 space-y-2 lg:col-span-4"> |
| 101 | + <div className="overflow-hidden rounded-lg border border-gray-200/70 bg-white shadow-xs transition-all"> |
| 102 | + <div className="border-b border-gray-200/70 bg-gradient-to-br from-gray-50/80 to-white px-5 py-4"> |
| 103 | + <h3 className="flex items-center gap-2 text-sm font-semibold text-gray-900"> |
| 104 | + <BookOpen className="text-primary h-4 w-4" /> |
| 105 | + Thông tin nhóm |
| 106 | + </h3> |
| 107 | + </div> |
| 108 | + <div className="space-y-3 px-5 py-4"> |
| 109 | + <div className="flex items-start gap-3"> |
| 110 | + <div className="bg-primary/10 text-primary flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg"> |
| 111 | + <BookOpen className="h-4 w-4" /> |
| 112 | + </div> |
| 113 | + <div className="flex-1"> |
| 114 | + <p className="text-xs font-medium text-gray-500">Đề tài</p> |
| 115 | + <p className="text-primary mt-0.5 text-sm leading-relaxed font-semibold"> |
| 116 | + {team.topic?.title || "Chưa có đề tài"} |
| 117 | + </p> |
| 118 | + {team.topic?.filePath && ( |
| 119 | + <a |
| 120 | + href={team.topic.filePath} |
| 121 | + target="_blank" |
| 122 | + rel="noopener noreferrer" |
| 123 | + className="text-primary mt-1 inline-block text-xs font-medium hover:underline" |
| 124 | + > |
| 125 | + Xem chi tiết đề tài → |
| 126 | + </a> |
| 127 | + )} |
| 128 | + </div> |
| 129 | + </div> |
| 130 | + <div className="flex items-start gap-3"> |
| 131 | + <div className="bg-primary/10 text-primary flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg"> |
| 132 | + <User className="h-4 w-4" /> |
| 133 | + </div> |
| 134 | + <div className="flex-1"> |
| 135 | + <p className="text-xs font-medium text-gray-500">Mentor</p> |
| 136 | + <p className="text-primary mt-0.5 text-sm font-semibold"> |
| 137 | + {team.mentorship?.mentor?.fullName || "Chưa có mentor"} |
| 138 | + </p> |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + |
| 144 | + <div className="overflow-hidden rounded-lg border border-amber-200/60 bg-gradient-to-br from-amber-50/50 to-white shadow-xs transition-all"> |
| 145 | + <div className="border-b border-amber-200/60 bg-gradient-to-br from-amber-50/80 to-white px-5 py-4"> |
| 146 | + <h3 className="flex items-center gap-2 text-sm font-semibold text-gray-900"> |
| 147 | + <Calendar className="h-4 w-4 text-amber-600" /> |
| 148 | + Lịch thuyết trình |
| 149 | + </h3> |
| 150 | + </div> |
| 151 | + <div className="space-y-3 px-5 py-4"> |
| 152 | + <div className="flex items-start gap-3"> |
| 153 | + <div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-amber-100/50 text-amber-600"> |
| 154 | + <Calendar className="h-4 w-4" /> |
| 155 | + </div> |
| 156 | + <div className="flex-1"> |
| 157 | + <p className="text-xs font-medium text-gray-500">Ngày</p> |
| 158 | + <p className="mt-0.5 text-xs font-semibold text-gray-900 italic"> |
| 159 | + Chưa mở |
| 160 | + </p> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | + <div className="flex items-start gap-3"> |
| 164 | + <div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-amber-100/50 text-amber-600"> |
| 165 | + <Clock className="h-4 w-4" /> |
| 166 | + </div> |
| 167 | + <div className="flex-1"> |
| 168 | + <p className="text-xs font-medium text-gray-500">Giờ</p> |
| 169 | + <p className="mt-0.5 text-xs font-semibold text-gray-900 italic"> |
| 170 | + Chưa mở |
| 171 | + </p> |
| 172 | + </div> |
| 173 | + </div> |
| 174 | + <div className="flex items-start gap-3"> |
| 175 | + <div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-amber-100/50 text-amber-600"> |
| 176 | + <BookOpen className="h-4 w-4" /> |
| 177 | + </div> |
| 178 | + <div className="flex-1"> |
| 179 | + <p className="text-xs font-medium text-gray-500">Địa điểm</p> |
| 180 | + <p className="mt-0.5 text-xs font-semibold text-gray-900 italic"> |
| 181 | + Chưa mở |
| 182 | + </p> |
| 183 | + </div> |
| 184 | + </div> |
| 185 | + </div> |
| 186 | + </div> |
| 187 | + </div> |
| 188 | + </div> |
| 189 | + </> |
| 190 | + ))} |
| 191 | + </section> |
| 192 | + </> |
| 193 | + ); |
| 194 | +}; |
| 195 | + |
| 196 | +export default TeamPage; |
0 commit comments