Seth0330 commited on
Commit
c616a87
·
verified ·
1 Parent(s): 987557e

Create ClassesTable.jsx

Browse files
frontend/src/components/admin/ClassesTable.jsx ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // frontend/src/components/admin/ClassesTable.jsx
2
+ import React from "react";
3
+
4
+ export default function ClassesTable({
5
+ classes = [],
6
+ isLoading,
7
+ onEdit,
8
+ onDelete,
9
+ onViewEnrollments,
10
+ }) {
11
+ if (isLoading) {
12
+ return (
13
+ <div className="py-6 text-sm text-stone-500">
14
+ Loading classes...
15
+ </div>
16
+ );
17
+ }
18
+
19
+ if (!classes.length) {
20
+ return (
21
+ <div className="py-6 text-sm text-stone-500">
22
+ No classes created yet.
23
+ </div>
24
+ );
25
+ }
26
+
27
+ return (
28
+ <div className="overflow-x-auto">
29
+ <table className="min-w-full text-sm">
30
+ <thead>
31
+ <tr className="text-left text-xs font-semibold text-stone-500 border-b border-stone-100">
32
+ <th className="py-2 pr-4">Class Name</th>
33
+ <th className="py-2 px-4">Plan</th>
34
+ <th className="py-2 px-4">Days</th>
35
+ <th className="py-2 px-4">Time</th>
36
+ <th className="py-2 px-4">Max Students</th>
37
+ <th className="py-2 pl-4 text-right">Actions</th>
38
+ </tr>
39
+ </thead>
40
+ <tbody>
41
+ {classes.map((cls) => (
42
+ <tr
43
+ key={cls.id}
44
+ className="border-b border-stone-100 last:border-0 hover:bg-stone-50/60"
45
+ >
46
+ <td className="py-3 pr-4 text-stone-900 font-medium">
47
+ {cls.name}
48
+ </td>
49
+ <td className="py-3 px-4 text-stone-700">
50
+ {cls.membership_plan_name || "-"}
51
+ </td>
52
+ <td className="py-3 px-4 text-stone-700">
53
+ {(cls.days_of_week || []).join(", ") || "-"}
54
+ </td>
55
+ <td className="py-3 px-4 text-stone-700">
56
+ {cls.class_time || "-"}
57
+ </td>
58
+ <td className="py-3 px-4 text-stone-700">
59
+ {cls.max_students ?? "-"}
60
+ </td>
61
+ <td className="py-3 pl-4 text-right">
62
+ <div className="inline-flex gap-2">
63
+ <button
64
+ type="button"
65
+ onClick={() => onViewEnrollments && onViewEnrollments(cls)}
66
+ className="text-xs font-medium text-purple-700 hover:text-purple-900"
67
+ >
68
+ Enrollments
69
+ </button>
70
+ <button
71
+ type="button"
72
+ onClick={() => onEdit && onEdit(cls)}
73
+ className="text-xs font-medium text-stone-700 hover:text-stone-900"
74
+ >
75
+ Edit
76
+ </button>
77
+ <button
78
+ type="button"
79
+ onClick={() => onDelete && onDelete(cls.id)}
80
+ className="text-xs font-medium text-red-600 hover:text-red-700"
81
+ >
82
+ Delete
83
+ </button>
84
+ </div>
85
+ </td>
86
+ </tr>
87
+ ))}
88
+ </tbody>
89
+ </table>
90
+ </div>
91
+ );
92
+ }