Fix dates not saving on Safari; show grade level under student name
Safari's native <input type="date"> gets reset by React's controlled value, so picked dates never reached state. Make date inputs uncontrolled (defaultValue + onChange) in the profile, academics, and public intake forms. Header now shows grade level instead of a single class. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ function StudentDetail() {
|
||||
<PhotoAvatar studentId={id} photoPath={student?.photo_path as string | null} canEdit={isAdmin} />
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">{student?.first_name} {student?.last_name}</h1>
|
||||
<p className="text-muted-foreground text-sm">{(student?.classes as { name: string } | null)?.name ?? "No class"}</p>
|
||||
<p className="text-muted-foreground text-sm">{student?.grade_level ? `Grade ${student.grade_level}` : "No grade level set"}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -234,7 +234,8 @@ function ProfileTab({ studentId, canEdit, isAdmin }: { studentId: string; canEdi
|
||||
|
||||
// ── Edit mode ──
|
||||
const T = (k: string, label: string) => <Field label={label}><Input value={val(k)} onChange={(e) => upd(k, e.target.value)} /></Field>;
|
||||
const D = (k: string, label: string) => <Field label={label}><Input type="date" value={val(k)} onChange={(e) => upd(k, e.target.value)} /></Field>;
|
||||
// Uncontrolled (defaultValue) so Safari's native date picker doesn't get reset by React's controlled value.
|
||||
const D = (k: string, label: string) => <Field label={label}><Input type="date" defaultValue={val(k)} onChange={(e) => upd(k, e.target.value)} /></Field>;
|
||||
const A = (k: string, label: string, rows = 2) => <Field label={label}><Textarea rows={rows} value={val(k)} onChange={(e) => upd(k, e.target.value)} /></Field>;
|
||||
return (
|
||||
<div className="bg-card border rounded-lg p-6 space-y-6 mt-4">
|
||||
@@ -601,7 +602,7 @@ function AcademicsTab({ studentId, canEdit }: { studentId: string; canEdit: bool
|
||||
) : (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<Field label="Home Ed. Annual Evaluation due to BPS"><Input type="date" value={val("home_ed_eval_due")} onChange={(e) => upd("home_ed_eval_due", e.target.value)} /></Field>
|
||||
<Field label="Home Ed. Annual Evaluation due to BPS"><Input type="date" defaultValue={val("home_ed_eval_due")} onChange={(e) => upd("home_ed_eval_due", e.target.value)} /></Field>
|
||||
<Field label="Previous school(s)"><Input value={val("previous_schools")} onChange={(e) => upd("previous_schools", e.target.value)} /></Field>
|
||||
</div>
|
||||
<Field label="Special academic needs / accommodations"><Textarea rows={2} value={val("special_needs")} onChange={(e) => upd("special_needs", e.target.value)} /></Field>
|
||||
|
||||
Reference in New Issue
Block a user