Skip to content

Commit abe8f5e

Browse files
committed
fix: update focus rings modal layouts
1 parent 6e8d63c commit abe8f5e

7 files changed

Lines changed: 576 additions & 261 deletions

File tree

backend/src/database/class_enrollments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ type EnrollmentDetails struct {
353353
func (db *DB) GetProgramClassEnrollmentsForProgram(args *models.QueryContext, classId int, status string) ([]EnrollmentDetails, error) {
354354
content := make([]EnrollmentDetails, 0, args.PerPage)
355355
search := args.SearchQuery()
356-
tx := db.WithContext(args.Ctx).Table("program_class_enrollments pse").Select("pse.*, u.name_last || ', ' || u.name_first as name_full, u.doc_id, c.name as class_name, c.start_dt, pc.created_at as completion_dt").
356+
tx := db.WithContext(args.Ctx).Table("program_class_enrollments pse").Select("pse.*, u.name_first || ' ' || u.name_last as name_full, u.doc_id, c.name as class_name, c.start_dt, pc.created_at as completion_dt").
357357
Joins("JOIN program_classes c ON pse.class_id = c.id AND c.deleted_at IS NULL").
358358
Joins("JOIN users u ON pse.user_id = u.id AND u.deleted_at IS NULL").
359359
Joins("LEFT JOIN program_completions pc ON pc.user_id = pse.user_id AND pc.program_class_id = ?", classId).

frontend-v2/src/pages/class-detail/ChangeClassStatusModal.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,30 @@ interface ChangeClassStatusModalProps {
3030
onStatusChanged: () => void;
3131
}
3232

33-
const STATUS_TRANSITIONS: Record<string, SelectedClassStatus[]> = {
34-
[SelectedClassStatus.Scheduled]: [
35-
SelectedClassStatus.Active,
36-
SelectedClassStatus.Cancelled
37-
],
38-
[SelectedClassStatus.Active]: [
39-
SelectedClassStatus.Paused,
40-
SelectedClassStatus.Completed
41-
],
42-
[SelectedClassStatus.Paused]: [
43-
SelectedClassStatus.Active,
44-
SelectedClassStatus.Cancelled
45-
]
46-
};
33+
const ALL_STATUSES: SelectedClassStatus[] = [
34+
SelectedClassStatus.Active,
35+
SelectedClassStatus.Scheduled,
36+
SelectedClassStatus.Paused,
37+
SelectedClassStatus.Completed,
38+
SelectedClassStatus.Cancelled
39+
];
40+
41+
function getStatusDescription(status: SelectedClassStatus): string {
42+
switch (status) {
43+
case SelectedClassStatus.Active:
44+
return 'Class is currently running and accepting attendance.';
45+
case SelectedClassStatus.Scheduled:
46+
return 'Class is scheduled to begin in the future.';
47+
case SelectedClassStatus.Paused:
48+
return 'Class is temporarily paused and hidden from daily attendance.';
49+
case SelectedClassStatus.Completed:
50+
return 'Class has finished and is now archived.';
51+
case SelectedClassStatus.Cancelled:
52+
return 'Class has been cancelled and will not take place.';
53+
default:
54+
return '';
55+
}
56+
}
4757

4858
export function ChangeClassStatusModal({
4959
open,
@@ -58,8 +68,6 @@ export function ChangeClassStatusModal({
5868
const [newStatus, setNewStatus] = useState<SelectedClassStatus>(currentStatus);
5969
const [isSubmitting, setIsSubmitting] = useState(false);
6070

61-
const allowedStatuses = STATUS_TRANSITIONS[currentStatus] ?? [];
62-
6371
useEffect(() => {
6472
if (open) {
6573
setNewStatus(currentStatus);
@@ -109,16 +117,16 @@ export function ChangeClassStatusModal({
109117
<SelectValue />
110118
</SelectTrigger>
111119
<SelectContent>
112-
<SelectItem value={currentStatus}>
113-
{currentStatus} (current)
114-
</SelectItem>
115-
{allowedStatuses.map((s) => (
120+
{ALL_STATUSES.map((s) => (
116121
<SelectItem key={s} value={s}>
117122
{s}
118123
</SelectItem>
119124
))}
120125
</SelectContent>
121126
</Select>
127+
<p className="text-xs text-gray-500 mt-2">
128+
{getStatusDescription(newStatus)}
129+
</p>
122130
</div>
123131
<div className="flex gap-2 justify-end pt-4">
124132
<Button

frontend-v2/src/pages/class-detail/ChangeEnrollmentStatusModal.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ interface ChangeEnrollmentStatusModalProps {
2828
onStatusChange: (newStatus: EnrollmentStatus, reason: string) => void;
2929
}
3030

31-
const NEEDS_REASON_STATUSES = new Set([
31+
const STATUSES_IN_ORDER: EnrollmentStatus[] = [
32+
EnrollmentStatus.Enrolled,
33+
EnrollmentStatus.Completed,
3234
EnrollmentStatus.Withdrawn,
3335
EnrollmentStatus.Dropped,
3436
EnrollmentStatus.Segregated,
35-
EnrollmentStatus['Failed To Complete'],
36-
EnrollmentStatus.Transfered,
37-
EnrollmentStatus.Cancelled
38-
]);
37+
EnrollmentStatus['Failed To Complete']
38+
];
3939

4040
export function ChangeEnrollmentStatusModal({
4141
open,
@@ -56,7 +56,9 @@ export function ChangeEnrollmentStatusModal({
5656
}
5757
}, [open, currentStatus]);
5858

59-
const needsReason = NEEDS_REASON_STATUSES.has(newStatus);
59+
const needsReason =
60+
newStatus !== EnrollmentStatus.Enrolled &&
61+
newStatus !== EnrollmentStatus.Completed;
6062
const canSubmit =
6163
newStatus !== currentStatus && (!needsReason || reason.trim().length > 0);
6264

@@ -65,6 +67,10 @@ export function ChangeEnrollmentStatusModal({
6567
onClose();
6668
};
6769

70+
const displayStatuses = STATUSES_IN_ORDER.filter(
71+
(s) => s === currentStatus || allowedStatuses.includes(s)
72+
);
73+
6874
return (
6975
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}>
7076
<DialogContent className="max-w-md">
@@ -88,10 +94,7 @@ export function ChangeEnrollmentStatusModal({
8894
<SelectValue />
8995
</SelectTrigger>
9096
<SelectContent>
91-
<SelectItem value={currentStatus}>
92-
{currentStatus}
93-
</SelectItem>
94-
{allowedStatuses.map((status) => (
97+
{displayStatuses.map((status) => (
9598
<SelectItem key={status} value={status}>
9699
{status}
97100
</SelectItem>
@@ -102,11 +105,11 @@ export function ChangeEnrollmentStatusModal({
102105
{needsReason && (
103106
<div>
104107
<Label htmlFor="reason">
105-
Reason for Status Change *
108+
Reason for Incompletion *
106109
</Label>
107110
<Textarea
108111
id="reason"
109-
placeholder="Explain why this resident's status is being changed..."
112+
placeholder="Explain why this resident did not complete the class..."
110113
value={reason}
111114
onChange={(e) => setReason(e.target.value)}
112115
rows={4}

0 commit comments

Comments
 (0)