Update frontend/src/components/admin/ClassStudentManager.jsx
Browse files
frontend/src/components/admin/ClassStudentManager.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
// frontend/src/components/admin/ClassStudentManager.jsx
|
| 2 |
import React, { useState, useMemo, useRef, useEffect } from "react";
|
| 3 |
-
import {
|
|
|
|
| 4 |
import client from "../../api/client";
|
| 5 |
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 6 |
|
|
@@ -300,31 +301,55 @@ export default function ClassStudentManager({ classData, onClose }) {
|
|
| 300 |
) : (
|
| 301 |
<div className="border-t border-stone-100 pt-4">
|
| 302 |
<div className="space-y-2">
|
| 303 |
-
{enrolledStudents.map((enrollment) =>
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
</div>
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
</div>
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
onClick={() => removeMutation.mutate(enrollment.id)}
|
| 321 |
-
disabled={removeMutation.isPending}
|
| 322 |
-
className="text-xs font-medium text-red-600 hover:text-red-700 disabled:opacity-50"
|
| 323 |
-
>
|
| 324 |
-
Remove
|
| 325 |
-
</button>
|
| 326 |
-
</div>
|
| 327 |
-
))}
|
| 328 |
</div>
|
| 329 |
</div>
|
| 330 |
)}
|
|
|
|
| 1 |
// frontend/src/components/admin/ClassStudentManager.jsx
|
| 2 |
import React, { useState, useMemo, useRef, useEffect } from "react";
|
| 3 |
+
import { Link } from "react-router-dom";
|
| 4 |
+
import { Users2, X, ChevronDown, Search, User } from "lucide-react";
|
| 5 |
import client from "../../api/client";
|
| 6 |
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 7 |
|
|
|
|
| 301 |
) : (
|
| 302 |
<div className="border-t border-stone-100 pt-4">
|
| 303 |
<div className="space-y-2">
|
| 304 |
+
{enrolledStudents.map((enrollment) => {
|
| 305 |
+
// Try to find the student by student_id or by matching email/name
|
| 306 |
+
const student = enrollment.student_id
|
| 307 |
+
? students.find((s) => s.id === enrollment.student_id)
|
| 308 |
+
: students.find(
|
| 309 |
+
(s) =>
|
| 310 |
+
s.membership_email === enrollment.student_email ||
|
| 311 |
+
`${s.first_name} ${s.last_name}` === enrollment.student_name
|
| 312 |
+
);
|
| 313 |
+
const studentId = student?.id || enrollment.student_id;
|
| 314 |
+
|
| 315 |
+
return (
|
| 316 |
+
<div
|
| 317 |
+
key={enrollment.id}
|
| 318 |
+
className="flex items-center justify-between py-2 px-3 rounded-lg hover:bg-stone-50"
|
| 319 |
+
>
|
| 320 |
+
<div className="flex items-center gap-2 flex-1">
|
| 321 |
+
<div className="flex-1">
|
| 322 |
+
<div className="font-medium text-stone-900 text-sm">
|
| 323 |
+
{enrollment.student_name || enrollment.student_email || "Unknown Student"}
|
| 324 |
+
</div>
|
| 325 |
+
{enrollment.student_email && enrollment.student_name && (
|
| 326 |
+
<div className="text-xs text-stone-500">
|
| 327 |
+
{enrollment.student_email}
|
| 328 |
+
</div>
|
| 329 |
+
)}
|
| 330 |
</div>
|
| 331 |
+
{studentId && (
|
| 332 |
+
<Link
|
| 333 |
+
to={`/admin/students/${studentId}`}
|
| 334 |
+
className="p-1 text-stone-600 hover:text-stone-900"
|
| 335 |
+
title="View Profile"
|
| 336 |
+
onClick={(e) => e.stopPropagation()}
|
| 337 |
+
>
|
| 338 |
+
<User className="w-4 h-4" />
|
| 339 |
+
</Link>
|
| 340 |
+
)}
|
| 341 |
+
</div>
|
| 342 |
+
<button
|
| 343 |
+
type="button"
|
| 344 |
+
onClick={() => removeMutation.mutate(enrollment.id)}
|
| 345 |
+
disabled={removeMutation.isPending}
|
| 346 |
+
className="text-xs font-medium text-red-600 hover:text-red-700 disabled:opacity-50 ml-2"
|
| 347 |
+
>
|
| 348 |
+
Remove
|
| 349 |
+
</button>
|
| 350 |
</div>
|
| 351 |
+
);
|
| 352 |
+
})}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
</div>
|
| 354 |
</div>
|
| 355 |
)}
|