Update frontend/src/components/admin/ClassesTable.jsx
Browse files
frontend/src/components/admin/ClassesTable.jsx
CHANGED
|
@@ -1,18 +1,5 @@
|
|
| 1 |
// frontend/src/components/admin/ClassesTable.jsx
|
| 2 |
import React from "react";
|
| 3 |
-
|
| 4 |
-
import {
|
| 5 |
-
Table,
|
| 6 |
-
TableBody,
|
| 7 |
-
TableCell,
|
| 8 |
-
TableHead,
|
| 9 |
-
TableHeader,
|
| 10 |
-
TableRow,
|
| 11 |
-
} from "../ui/table";
|
| 12 |
-
import { Button } from "../ui/button";
|
| 13 |
-
import { Badge } from "../ui/badge";
|
| 14 |
-
import { Card } from "../ui/card";
|
| 15 |
-
import { Skeleton } from "../ui/skeleton";
|
| 16 |
import { Edit2, Trash2, Users } from "lucide-react";
|
| 17 |
|
| 18 |
export default function ClassesTable({
|
|
@@ -26,7 +13,10 @@ export default function ClassesTable({
|
|
| 26 |
return (
|
| 27 |
<div className="space-y-3">
|
| 28 |
{[1, 2, 3].map((i) => (
|
| 29 |
-
<
|
|
|
|
|
|
|
|
|
|
| 30 |
))}
|
| 31 |
</div>
|
| 32 |
);
|
|
@@ -42,31 +32,41 @@ export default function ClassesTable({
|
|
| 42 |
|
| 43 |
return (
|
| 44 |
<>
|
| 45 |
-
{/* Desktop
|
| 46 |
<div className="hidden md:block overflow-x-auto">
|
| 47 |
-
<
|
| 48 |
-
<
|
| 49 |
-
<
|
| 50 |
-
<
|
| 51 |
-
|
| 52 |
-
<
|
| 53 |
-
<
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
{classes.map((cls) => (
|
| 58 |
-
<
|
| 59 |
-
<
|
| 60 |
<div>
|
| 61 |
-
<div className="font-medium">
|
|
|
|
|
|
|
| 62 |
{cls.description && (
|
| 63 |
-
<div className="text-xs text-stone-500
|
| 64 |
{cls.description}
|
| 65 |
</div>
|
| 66 |
)}
|
| 67 |
</div>
|
| 68 |
-
</
|
| 69 |
-
<
|
| 70 |
<div className="space-y-1 text-sm">
|
| 71 |
{(cls.schedule || []).map((slot, idx) => (
|
| 72 |
<div key={idx}>
|
|
@@ -77,55 +77,68 @@ export default function ClassesTable({
|
|
| 77 |
</div>
|
| 78 |
))}
|
| 79 |
</div>
|
| 80 |
-
</
|
| 81 |
-
<
|
| 82 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
{cls.is_active ? "Active" : "Inactive"}
|
| 84 |
-
</
|
| 85 |
-
</
|
| 86 |
-
<
|
| 87 |
<div className="flex justify-end gap-2">
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
size="sm"
|
| 91 |
onClick={() => onManageStudents(cls)}
|
| 92 |
-
className="gap-2"
|
| 93 |
>
|
| 94 |
<Users className="w-4 h-4" />
|
| 95 |
Students
|
| 96 |
-
</
|
| 97 |
-
<
|
| 98 |
-
|
| 99 |
-
size="icon"
|
| 100 |
onClick={() => onEdit(cls)}
|
|
|
|
| 101 |
>
|
| 102 |
<Edit2 className="w-4 h-4" />
|
| 103 |
-
</
|
| 104 |
-
<
|
| 105 |
-
|
| 106 |
-
size="icon"
|
| 107 |
onClick={() => onDelete(cls.id)}
|
| 108 |
-
className="text-red-
|
| 109 |
>
|
| 110 |
<Trash2 className="w-4 h-4" />
|
| 111 |
-
</
|
| 112 |
</div>
|
| 113 |
-
</
|
| 114 |
-
</
|
| 115 |
))}
|
| 116 |
-
</
|
| 117 |
-
</
|
| 118 |
</div>
|
| 119 |
|
| 120 |
-
{/* Mobile
|
| 121 |
<div className="md:hidden space-y-3">
|
| 122 |
{classes.map((cls) => (
|
| 123 |
-
<
|
|
|
|
|
|
|
|
|
|
| 124 |
<div className="flex justify-between items-start mb-2">
|
| 125 |
<div className="font-semibold text-stone-900">{cls.name}</div>
|
| 126 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
{cls.is_active ? "Active" : "Inactive"}
|
| 128 |
-
</
|
| 129 |
</div>
|
| 130 |
{cls.description && (
|
| 131 |
<p className="text-sm text-stone-600 mb-3">
|
|
@@ -143,32 +156,30 @@ export default function ClassesTable({
|
|
| 143 |
))}
|
| 144 |
</div>
|
| 145 |
<div className="flex gap-2">
|
| 146 |
-
<
|
| 147 |
-
|
| 148 |
-
size="sm"
|
| 149 |
onClick={() => onManageStudents(cls)}
|
| 150 |
-
className="flex-1 gap-2"
|
| 151 |
>
|
| 152 |
<Users className="w-4 h-4" />
|
| 153 |
Students
|
| 154 |
-
</
|
| 155 |
-
<
|
| 156 |
-
|
| 157 |
-
size="icon"
|
| 158 |
onClick={() => onEdit(cls)}
|
|
|
|
| 159 |
>
|
| 160 |
<Edit2 className="w-4 h-4" />
|
| 161 |
-
</
|
| 162 |
-
<
|
| 163 |
-
|
| 164 |
-
size="icon"
|
| 165 |
onClick={() => onDelete(cls.id)}
|
| 166 |
-
className="text-red-
|
| 167 |
>
|
| 168 |
<Trash2 className="w-4 h-4" />
|
| 169 |
-
</
|
| 170 |
</div>
|
| 171 |
-
</
|
| 172 |
))}
|
| 173 |
</div>
|
| 174 |
</>
|
|
|
|
| 1 |
// frontend/src/components/admin/ClassesTable.jsx
|
| 2 |
import React from "react";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import { Edit2, Trash2, Users } from "lucide-react";
|
| 4 |
|
| 5 |
export default function ClassesTable({
|
|
|
|
| 13 |
return (
|
| 14 |
<div className="space-y-3">
|
| 15 |
{[1, 2, 3].map((i) => (
|
| 16 |
+
<div
|
| 17 |
+
key={i}
|
| 18 |
+
className="h-16 w-full animate-pulse rounded-md bg-stone-100"
|
| 19 |
+
/>
|
| 20 |
))}
|
| 21 |
</div>
|
| 22 |
);
|
|
|
|
| 32 |
|
| 33 |
return (
|
| 34 |
<>
|
| 35 |
+
{/* Desktop table */}
|
| 36 |
<div className="hidden md:block overflow-x-auto">
|
| 37 |
+
<table className="min-w-full text-sm border border-stone-200 rounded-lg overflow-hidden">
|
| 38 |
+
<thead className="bg-stone-50">
|
| 39 |
+
<tr>
|
| 40 |
+
<th className="px-4 py-2 text-left font-semibold text-stone-800">
|
| 41 |
+
Class Name
|
| 42 |
+
</th>
|
| 43 |
+
<th className="px-4 py-2 text-left font-semibold text-stone-800">
|
| 44 |
+
Schedule
|
| 45 |
+
</th>
|
| 46 |
+
<th className="px-4 py-2 text-left font-semibold text-stone-800">
|
| 47 |
+
Status
|
| 48 |
+
</th>
|
| 49 |
+
<th className="px-4 py-2 text-right font-semibold text-stone-800">
|
| 50 |
+
Actions
|
| 51 |
+
</th>
|
| 52 |
+
</tr>
|
| 53 |
+
</thead>
|
| 54 |
+
<tbody>
|
| 55 |
{classes.map((cls) => (
|
| 56 |
+
<tr key={cls.id} className="border-t border-stone-200">
|
| 57 |
+
<td className="px-4 py-3 align-top">
|
| 58 |
<div>
|
| 59 |
+
<div className="font-medium text-stone-900">
|
| 60 |
+
{cls.name}
|
| 61 |
+
</div>
|
| 62 |
{cls.description && (
|
| 63 |
+
<div className="text-xs text-stone-500 max-w-xs truncate">
|
| 64 |
{cls.description}
|
| 65 |
</div>
|
| 66 |
)}
|
| 67 |
</div>
|
| 68 |
+
</td>
|
| 69 |
+
<td className="px-4 py-3 align-top">
|
| 70 |
<div className="space-y-1 text-sm">
|
| 71 |
{(cls.schedule || []).map((slot, idx) => (
|
| 72 |
<div key={idx}>
|
|
|
|
| 77 |
</div>
|
| 78 |
))}
|
| 79 |
</div>
|
| 80 |
+
</td>
|
| 81 |
+
<td className="px-4 py-3 align-top">
|
| 82 |
+
<span
|
| 83 |
+
className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${
|
| 84 |
+
cls.is_active
|
| 85 |
+
? "bg-green-100 text-green-800"
|
| 86 |
+
: "bg-stone-200 text-stone-700"
|
| 87 |
+
}`}
|
| 88 |
+
>
|
| 89 |
{cls.is_active ? "Active" : "Inactive"}
|
| 90 |
+
</span>
|
| 91 |
+
</td>
|
| 92 |
+
<td className="px-4 py-3 align-top text-right">
|
| 93 |
<div className="flex justify-end gap-2">
|
| 94 |
+
<button
|
| 95 |
+
type="button"
|
|
|
|
| 96 |
onClick={() => onManageStudents(cls)}
|
| 97 |
+
className="inline-flex items-center gap-1 rounded-md border border-stone-300 px-2.5 py-1 text-xs font-medium text-stone-800 hover:bg-stone-50"
|
| 98 |
>
|
| 99 |
<Users className="w-4 h-4" />
|
| 100 |
Students
|
| 101 |
+
</button>
|
| 102 |
+
<button
|
| 103 |
+
type="button"
|
|
|
|
| 104 |
onClick={() => onEdit(cls)}
|
| 105 |
+
className="inline-flex items-center justify-center rounded-md border border-stone-300 px-2.5 py-1 text-xs text-stone-800 hover:bg-stone-50"
|
| 106 |
>
|
| 107 |
<Edit2 className="w-4 h-4" />
|
| 108 |
+
</button>
|
| 109 |
+
<button
|
| 110 |
+
type="button"
|
|
|
|
| 111 |
onClick={() => onDelete(cls.id)}
|
| 112 |
+
className="inline-flex items-center justify-center rounded-md border border-red-200 px-2.5 py-1 text-xs text-red-700 hover:bg-red-50"
|
| 113 |
>
|
| 114 |
<Trash2 className="w-4 h-4" />
|
| 115 |
+
</button>
|
| 116 |
</div>
|
| 117 |
+
</td>
|
| 118 |
+
</tr>
|
| 119 |
))}
|
| 120 |
+
</tbody>
|
| 121 |
+
</table>
|
| 122 |
</div>
|
| 123 |
|
| 124 |
+
{/* Mobile cards */}
|
| 125 |
<div className="md:hidden space-y-3">
|
| 126 |
{classes.map((cls) => (
|
| 127 |
+
<div
|
| 128 |
+
key={cls.id}
|
| 129 |
+
className="rounded-lg border border-stone-200 p-4 bg-white shadow-sm"
|
| 130 |
+
>
|
| 131 |
<div className="flex justify-between items-start mb-2">
|
| 132 |
<div className="font-semibold text-stone-900">{cls.name}</div>
|
| 133 |
+
<span
|
| 134 |
+
className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${
|
| 135 |
+
cls.is_active
|
| 136 |
+
? "bg-green-100 text-green-800"
|
| 137 |
+
: "bg-stone-200 text-stone-700"
|
| 138 |
+
}`}
|
| 139 |
+
>
|
| 140 |
{cls.is_active ? "Active" : "Inactive"}
|
| 141 |
+
</span>
|
| 142 |
</div>
|
| 143 |
{cls.description && (
|
| 144 |
<p className="text-sm text-stone-600 mb-3">
|
|
|
|
| 156 |
))}
|
| 157 |
</div>
|
| 158 |
<div className="flex gap-2">
|
| 159 |
+
<button
|
| 160 |
+
type="button"
|
|
|
|
| 161 |
onClick={() => onManageStudents(cls)}
|
| 162 |
+
className="flex-1 inline-flex items-center justify-center gap-1 rounded-md border border-stone-300 px-2.5 py-1.5 text-xs font-medium text-stone-800 hover:bg-stone-50"
|
| 163 |
>
|
| 164 |
<Users className="w-4 h-4" />
|
| 165 |
Students
|
| 166 |
+
</button>
|
| 167 |
+
<button
|
| 168 |
+
type="button"
|
|
|
|
| 169 |
onClick={() => onEdit(cls)}
|
| 170 |
+
className="inline-flex items-center justify-center rounded-md border border-stone-300 px-2.5 py-1.5 text-xs text-stone-800 hover:bg-stone-50"
|
| 171 |
>
|
| 172 |
<Edit2 className="w-4 h-4" />
|
| 173 |
+
</button>
|
| 174 |
+
<button
|
| 175 |
+
type="button"
|
|
|
|
| 176 |
onClick={() => onDelete(cls.id)}
|
| 177 |
+
className="inline-flex items-center justify-center rounded-md border border-red-200 px-2.5 py-1.5 text-xs text-red-700 hover:bg-red-50"
|
| 178 |
>
|
| 179 |
<Trash2 className="w-4 h-4" />
|
| 180 |
+
</button>
|
| 181 |
</div>
|
| 182 |
+
</div>
|
| 183 |
))}
|
| 184 |
</div>
|
| 185 |
</>
|