forge
Explore
Log in

Don't you dare go Hollow

🛟 the unsaved-input guard covers every form panel

Browse files at this commit

b507ba2a89bc29ad7e3ffeeca5d0e9c360fcc701Burak BoduroğluParent: 1747ea7
  • feat
    • 🛟 the unsaved-input guard covers every form panel
Show full message
feat: 🛟 the unsaved-input guard covers every form panel
- guardUnsaved on 37 create/edit side panels: users, schools, blueprints,
  subjects, notes, homework and grading, sessions, academic years, terms,
  appointments, bank questions, classes, courses, events, exam edit and
  grading, meals, payments, profiles, staff work, whiteboards
- left off: single-person pickers (little to lose), the multi-step exam
  create panels past their first step, and read-only panels
src/components/builder/create-school-panel.tsxmodified+1 -1
@@ -68,7 +68,7 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
68 };68 };
69 69
70 return (70 return (
71- <SidePanel71+ <SidePanel guardUnsaved
72 size="wide"72 size="wide"
73 open={props.open}73 open={props.open}
74 onOpenChange={(open) => {74 onOpenChange={(open) => {
src/components/builder/school-admin-access-panel.tsxmodified+1 -1
@@ -56,7 +56,7 @@ export function SchoolAdminAccessPanel(props: {
56 };56 };
57 57
58 return (58 return (
59- <SidePanel59+ <SidePanel guardUnsaved
60 open={props.mode != null}60 open={props.mode != null}
61 onOpenChange={(open) => {61 onOpenChange={(open) => {
62 if (!open) {62 if (!open) {
src/components/classes/blueprint-panel.tsxmodified+1 -1
@@ -101,7 +101,7 @@ export function BlueprintPanel(props: {
101 };101 };
102 102
103 return (103 return (
104- <SidePanel104+ <SidePanel guardUnsaved
105 open={props.open}105 open={props.open}
106 onOpenChange={props.onOpenChange}106 onOpenChange={props.onOpenChange}
107 title={editing() ? t("classBlueprints.edit") : t("classBlueprints.new")}107 title={editing() ? t("classBlueprints.edit") : t("classBlueprints.new")}
src/components/courses/course-notes-panel.tsxmodified+1 -1
@@ -67,7 +67,7 @@ export function CourseNotesPanel(props: {
67 </Show>67 </Show>
68 68
69 <Show when={props.canManage}>69 <Show when={props.canManage}>
70- <SidePanel open={props.createOpen} onOpenChange={props.onCreateOpenChange} title={t("courseNotes.new")}>70+ <SidePanel guardUnsaved open={props.createOpen} onOpenChange={props.onCreateOpenChange} title={t("courseNotes.new")}>
71 <NoteForm71 <NoteForm
72 enableFiles72 enableFiles
73 submitLabel={t("common.create")}73 submitLabel={t("common.create")}
src/components/courses/course-subjects-panel.tsxmodified+1 -1
@@ -112,7 +112,7 @@ export function CourseSubjectsPanel(props: { courseId: string; canManage: boolea
112 <Show when={flash()}>112 <Show when={flash()}>
113 <Alert variant="success">{flash()}</Alert>113 <Alert variant="success">{flash()}</Alert>
114 </Show>114 </Show>
115- <SidePanel open={props.createOpen} onOpenChange={setPanelOpen} title={editing() ? t("subjects.edit") : t("subjects.add")} description={t("subjects.help")}>115+ <SidePanel guardUnsaved open={props.createOpen} onOpenChange={setPanelOpen} title={editing() ? t("subjects.edit") : t("subjects.add")} description={t("subjects.help")}>
116 <form class="space-y-3" onSubmit={(event) => void save(event)}>116 <form class="space-y-3" onSubmit={(event) => void save(event)}>
117 <div class="space-y-1.5">117 <div class="space-y-1.5">
118 <Label for="subject-name">{t("subjects.name")}</Label>118 <Label for="subject-name">{t("subjects.name")}</Label>
src/components/homework/course-homework-panel.tsxmodified+1 -1
@@ -217,7 +217,7 @@ export function CourseHomeworkPanel(props: {
217 </Show>217 </Show>
218 </Suspense>218 </Suspense>
219 219
220- <SidePanel open={props.createOpen} onOpenChange={setPanelOpen} title={editing() ? t("homework.edit") : t("homework.add")} description={t("homework.help")}>220+ <SidePanel guardUnsaved open={props.createOpen} onOpenChange={setPanelOpen} title={editing() ? t("homework.edit") : t("homework.add")} description={t("homework.help")}>
221 <form class="space-y-4" onSubmit={(event) => void save(event)}>221 <form class="space-y-4" onSubmit={(event) => void save(event)}>
222 <Show when={error()}>222 <Show when={error()}>
223 <Alert variant="destructive">{error()}</Alert>223 <Alert variant="destructive">{error()}</Alert>
src/components/homework/homework-submissions-panel.tsxmodified+1 -1
@@ -155,7 +155,7 @@ export function HomeworkSubmissionsPanel(props: { homeworkId: string; instanceId
155 <Show when={submissions.error}><Alert variant="destructive">{formatApiError(submissions.error, locale())}</Alert></Show>155 <Show when={submissions.error}><Alert variant="destructive">{formatApiError(submissions.error, locale())}</Alert></Show>
156 <DataTable columns={columns()} data={submissions()?.items ?? []} filterColumn="user" enablePagination pageSize={10} empty={t("common.noResults")} />156 <DataTable columns={columns()} data={submissions()?.items ?? []} filterColumn="user" enablePagination pageSize={10} empty={t("common.noResults")} />
157 </Suspense>157 </Suspense>
158- <SidePanel open={gradeTarget() != null} onOpenChange={(open) => !open && closeGrade()} title={t("homework.grade")} description={gradeTarget() ? studentLabel(gradeTarget()!.user) : ""}>158+ <SidePanel guardUnsaved open={gradeTarget() != null} onOpenChange={(open) => !open && closeGrade()} title={t("homework.grade")} description={gradeTarget() ? studentLabel(gradeTarget()!.user) : ""}>
159 <form class="space-y-4" onSubmit={(event) => void saveGrade(event)}>159 <form class="space-y-4" onSubmit={(event) => void saveGrade(event)}>
160 <Show when={error()}><Alert variant="destructive">{error()}</Alert></Show>160 <Show when={error()}><Alert variant="destructive">{error()}</Alert></Show>
161 <div class="space-y-1.5">161 <div class="space-y-1.5">
src/components/notes/note-card.tsxmodified+1 -1
@@ -75,7 +75,7 @@ export function NoteCard(props: {
75 {error() && <p class="mt-2 text-sm text-destructive-text">{error()}</p>}75 {error() && <p class="mt-2 text-sm text-destructive-text">{error()}</p>}
76 </article>76 </article>
77 77
78- <SidePanel open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={props.note.title}>78+ <SidePanel guardUnsaved open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={props.note.title}>
79 <NoteForm79 <NoteForm
80 initial={props.note}80 initial={props.note}
81 submitLabel={t("common.update")}81 submitLabel={t("common.update")}
src/components/sessions/course-sessions-panel.tsxmodified+1 -1
@@ -265,7 +265,7 @@ export function CourseSessionsPanel(props: {
265 />265 />
266 </Suspense>266 </Suspense>
267 267
268- <SidePanel268+ <SidePanel guardUnsaved
269 open={panelOpen()}269 open={panelOpen()}
270 onOpenChange={(open) => {270 onOpenChange={(open) => {
271 if (!open) {271 if (!open) {
src/components/users/create-user-panel.tsxmodified+1 -1
@@ -74,7 +74,7 @@ export function CreateUserPanel(props: {
74 };74 };
75 75
76 return (76 return (
77- <SidePanel77+ <SidePanel guardUnsaved
78 open={props.open}78 open={props.open}
79 onOpenChange={(open) => { if (!open) close(); }}79 onOpenChange={(open) => { if (!open) close(); }}
80 title={t("admin.createUser")}80 title={t("admin.createUser")}
src/pages/academic-years-page.tsxmodified+2 -2
@@ -255,7 +255,7 @@ function AcademicYearsContent() {
255 </Suspense>255 </Suspense>
256 </section>256 </section>
257 257
258- <SidePanel258+ <SidePanel guardUnsaved
259 open={panelOpen()}259 open={panelOpen()}
260 onOpenChange={(open) => {260 onOpenChange={(open) => {
261 setPanelOpen(open);261 setPanelOpen(open);
@@ -347,7 +347,7 @@ function AcademicYearsContent() {
347 </form>347 </form>
348 </SidePanel>348 </SidePanel>
349 349
350- <SidePanel350+ <SidePanel guardUnsaved
351 open={rolloverTarget() !== null}351 open={rolloverTarget() !== null}
352 onOpenChange={(open) => !open && setRolloverTarget(null)}352 onOpenChange={(open) => !open && setRolloverTarget(null)}
353 title={t("academicYears.rollover")}353 title={t("academicYears.rollover")}
src/pages/admin-user-detail-page.tsxmodified+1 -1
@@ -133,7 +133,7 @@ function AdminUserDetailContent() {
133 </div>133 </div>
134 </section>134 </section>
135 135
136- <SidePanel136+ <SidePanel guardUnsaved
137 open={editing()}137 open={editing()}
138 onOpenChange={setEditing}138 onOpenChange={setEditing}
139 title={t("profile.edit")}139 title={t("profile.edit")}
src/pages/appointments-page.tsxmodified+3 -3
@@ -369,7 +369,7 @@ function AppointmentsContent() {
369 369
370 return (370 return (
371 <div class="space-y-5">371 <div class="space-y-5">
372- <SidePanel open={showPublish()} onOpenChange={setShowPublish} title={t("appointments.publish")} description={t("appointments.publishSubtitle")}>372+ <SidePanel guardUnsaved open={showPublish()} onOpenChange={setShowPublish} title={t("appointments.publish")} description={t("appointments.publishSubtitle")}>
373 <PublishSlotsForm373 <PublishSlotsForm
374 onCancel={() => setShowPublish(false)}374 onCancel={() => setShowPublish(false)}
375 onSubmit={async (values) => {375 onSubmit={async (values) => {
@@ -387,7 +387,7 @@ function AppointmentsContent() {
387 />387 />
388 </SidePanel>388 </SidePanel>
389 389
390- <SidePanel open={bookSlot() != null} onOpenChange={(o) => !o && setBookSlot(null)} title={t("appointments.book")} description={t("appointments.bookSubtitle")}>390+ <SidePanel guardUnsaved open={bookSlot() != null} onOpenChange={(o) => !o && setBookSlot(null)} title={t("appointments.book")} description={t("appointments.bookSubtitle")}>
391 <Show when={bookSlot()}>391 <Show when={bookSlot()}>
392 {(slot) => (392 {(slot) => (
393 <BookAppointmentForm393 <BookAppointmentForm
@@ -411,7 +411,7 @@ function AppointmentsContent() {
411 </Show>411 </Show>
412 </SidePanel>412 </SidePanel>
413 413
414- <SidePanel open={reschedAppt() != null} onOpenChange={(o) => !o && setReschedAppt(null)} title={t("appointments.reschedule")} description={t("appointments.rescheduleSubtitle")}>414+ <SidePanel guardUnsaved open={reschedAppt() != null} onOpenChange={(o) => !o && setReschedAppt(null)} title={t("appointments.reschedule")} description={t("appointments.rescheduleSubtitle")}>
415 <Show when={reschedAppt()}>415 <Show when={reschedAppt()}>
416 {(appt) => (416 {(appt) => (
417 <RescheduleForm417 <RescheduleForm
src/pages/bank-question-detail-page.tsxmodified+1 -1
@@ -196,7 +196,7 @@ function BankQuestionDetailContent() {
196 </Show>196 </Show>
197 </section>197 </section>
198 198
199- <SidePanel open={editing()} onOpenChange={setEditing} title={t("bank.edit")} description={current().text} size="wide">199+ <SidePanel guardUnsaved open={editing()} onOpenChange={setEditing} title={t("bank.edit")} description={current().text} size="wide">
200 <BankQuestionForm200 <BankQuestionForm
201 initial={current()}201 initial={current()}
202 courses={manageableCourses()}202 courses={manageableCourses()}
src/pages/builder-school-detail-page.tsxmodified+1 -1
@@ -188,7 +188,7 @@ function BuilderSchoolDetailContent() {
188 </Show>188 </Show>
189 </Suspense>189 </Suspense>
190 190
191- <SidePanel open={editOpen()} onOpenChange={setEditOpen} title={t("builder.editSchool")} description={t("builder.editSchoolHint")}>191+ <SidePanel guardUnsaved open={editOpen()} onOpenChange={setEditOpen} title={t("builder.editSchool")} description={t("builder.editSchoolHint")}>
192 <form class="space-y-4" onSubmit={saveEdit}>192 <form class="space-y-4" onSubmit={saveEdit}>
193 <Show when={editError()}>193 <Show when={editError()}>
194 <Alert variant="destructive">{editError()}</Alert>194 <Alert variant="destructive">{editError()}</Alert>
src/pages/class-detail-page.tsxmodified+2 -2
@@ -312,7 +312,7 @@ function ClassDetailContent() {
312 </Tabs>312 </Tabs>
313 313
314 {/* Edit class */}314 {/* Edit class */}
315- <SidePanel open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={c().name}>315+ <SidePanel guardUnsaved open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={c().name}>
316 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void wrap(async () => { await patchClassById(id(), { name: name().trim(), grade: grade().trim() || null, year: yearId() || null, teacher_id: teacherId() || null }); setEditing(false); await refresh(refetchClass); }, "common.saved"); }}>316 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void wrap(async () => { await patchClassById(id(), { name: name().trim(), grade: grade().trim() || null, year: yearId() || null, teacher_id: teacherId() || null }); setEditing(false); await refresh(refetchClass); }, "common.saved"); }}>
317 <div class="space-y-3">317 <div class="space-y-3">
318 <div class="space-y-1.5"><Label for="edit-class-name">{t("classGroups.className")}</Label><Input id="edit-class-name" maxlength={limits.latest?.course.max_class_name_len} value={name()} onInput={(e) => setName(e.currentTarget.value)} /></div>318 <div class="space-y-1.5"><Label for="edit-class-name">{t("classGroups.className")}</Label><Input id="edit-class-name" maxlength={limits.latest?.course.max_class_name_len} value={name()} onInput={(e) => setName(e.currentTarget.value)} /></div>
@@ -333,7 +333,7 @@ function ClassDetailContent() {
333 </SidePanel>333 </SidePanel>
334 334
335 {/* Attach course */}335 {/* Attach course */}
336- <SidePanel open={showAttachCourse()} onOpenChange={setShowAttachCourse} title={t("classGroups.attachCourse")} description={t("classGroups.attachCourseHelp")}>336+ <SidePanel guardUnsaved open={showAttachCourse()} onOpenChange={setShowAttachCourse} title={t("classGroups.attachCourse")} description={t("classGroups.attachCourseHelp")}>
337 <form class="space-y-3" onSubmit={(e) => { e.preventDefault(); const cid = attachCourseId(); if (!cid) return; void wrap(async () => { await postClassInstance(id(), { course_id: cid }); setAttachCourseId(""); setShowAttachCourse(false); await refresh(refetchCourses); }, "common.saved"); }}>337 <form class="space-y-3" onSubmit={(e) => { e.preventDefault(); const cid = attachCourseId(); if (!cid) return; void wrap(async () => { await postClassInstance(id(), { course_id: cid }); setAttachCourseId(""); setShowAttachCourse(false); await refresh(refetchCourses); }, "common.saved"); }}>
338 <div class="space-y-1.5">338 <div class="space-y-1.5">
339 <Label for="class-attach-course">{t("classGroups.selectCourse")}</Label>339 <Label for="class-attach-course">{t("classGroups.selectCourse")}</Label>
src/pages/course-detail-page.tsxmodified+1 -1
@@ -355,7 +355,7 @@ function CourseDetailContent() {
355 }}355 }}
356 />356 />
357 357
358- <SidePanel open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={c().title}>358+ <SidePanel guardUnsaved open={editing()} onOpenChange={setEditing} title={t("common.edit")} description={c().title}>
359 <form359 <form
360 class="space-y-4"360 class="space-y-4"
361 onSubmit={(e) => {361 onSubmit={(e) => {
src/pages/courses-page.tsxmodified+1 -1
@@ -114,7 +114,7 @@ function CoursesContent() {
114 114
115 return (115 return (
116 <div class="space-y-6">116 <div class="space-y-6">
117- <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: kindInSentence() })} description={t("courses.subtitle", { item: kindLabel() })}>117+ <SidePanel guardUnsaved open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: kindInSentence() })} description={t("courses.subtitle", { item: kindLabel() })}>
118 <form class="space-y-4" onSubmit={createCourse}>118 <form class="space-y-4" onSubmit={createCourse}>
119 <Show when={limits.error}><ErrorAlert message={formatApiError(limits.error)} onRetry={() => void refetchLimits()} /></Show>119 <Show when={limits.error}><ErrorAlert message={formatApiError(limits.error)} onRetry={() => void refetchLimits()} /></Show>
120 <div class="flex items-center justify-between rounded-xl border border-border-line bg-surface-tint px-3 py-2 text-xs text-text-subtle">120 <div class="flex items-center justify-between rounded-xl border border-border-line bg-surface-tint px-3 py-2 text-xs text-text-subtle">
src/pages/event-detail-page.tsxmodified+1 -1
@@ -217,7 +217,7 @@ function EventDetailContent() {
217 }}217 }}
218 />218 />
219 219
220- <SidePanel220+ <SidePanel guardUnsaved
221 open={editing()}221 open={editing()}
222 onOpenChange={setEditing}222 onOpenChange={setEditing}
223 title={t("common.edit")}223 title={t("common.edit")}
src/pages/events-page.tsxmodified+1 -1
@@ -160,7 +160,7 @@ function EventsContent() {
160 160
161 return (161 return (
162 <div class="space-y-6">162 <div class="space-y-6">
163- <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("events.create")} description={t("events.subtitle")}>163+ <SidePanel guardUnsaved open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("events.create")} description={t("events.subtitle")}>
164 <EventForm164 <EventForm
165 submitLabel={t("common.create")}165 submitLabel={t("common.create")}
166 onCancel={() => setShowForm(false)}166 onCancel={() => setShowForm(false)}
src/pages/exam-detail-page.tsxmodified+2 -2
@@ -606,7 +606,7 @@ function ExamDetailContent() {
606 }}606 }}
607 />607 />
608 608
609- <SidePanel609+ <SidePanel guardUnsaved
610 open={editing()}610 open={editing()}
611 onOpenChange={setEditing}611 onOpenChange={setEditing}
612 title={t("common.edit")}612 title={t("common.edit")}
@@ -742,7 +742,7 @@ function ExamDetailContent() {
742 </TabsContent>742 </TabsContent>
743 </Tabs>743 </Tabs>
744 744
745- <SidePanel745+ <SidePanel guardUnsaved
746 open={gradeOpen()}746 open={gradeOpen()}
747 onOpenChange={setGradeOpen}747 onOpenChange={setGradeOpen}
748 title={t("exams.gradeStudent")}748 title={t("exams.gradeStudent")}
src/pages/homework-page.tsxmodified+1 -1
@@ -210,7 +210,7 @@ function HomeworkContent() {
210 210
211 return (211 return (
212 <div class="space-y-6">212 <div class="space-y-6">
213- <SidePanel open={createOpen()} onOpenChange={(open) => { setCreateOpen(open); if (!open) resetForm(); }} title={t("homework.add")} description={t("homework.help")}>213+ <SidePanel guardUnsaved open={createOpen()} onOpenChange={(open) => { setCreateOpen(open); if (!open) resetForm(); }} title={t("homework.add")} description={t("homework.help")}>
214 <form class="space-y-4" onSubmit={(event) => void save(event)}>214 <form class="space-y-4" onSubmit={(event) => void save(event)}>
215 <Show when={error()}>215 <Show when={error()}>
216 <Alert variant="destructive">{error()}</Alert>216 <Alert variant="destructive">{error()}</Alert>
src/pages/meal-detail-page.tsxmodified+2 -2
@@ -285,10 +285,10 @@ function MealDetailContent() {
285 <ConfirmDialog open={deleteMenuOpen()} onOpenChange={setDeleteMenuOpen} title={t("meals.deleteMenu")} variant="destructive" summary={`${current().date} · ${current().slot}`} onConfirm={() => run(async () => { await deleteMealMenuById(id()); void navigate({ to: "/meals" }); }, t("common.deleted"))} />285 <ConfirmDialog open={deleteMenuOpen()} onOpenChange={setDeleteMenuOpen} title={t("meals.deleteMenu")} variant="destructive" summary={`${current().date} · ${current().slot}`} onConfirm={() => run(async () => { await deleteMealMenuById(id()); void navigate({ to: "/meals" }); }, t("common.deleted"))} />
286 <ConfirmDialog open={deleteDish() !== null} onOpenChange={(open) => !open && setDeleteDish(null)} title={t("meals.deleteDish")} variant="destructive" summary={deleteDish()?.name ?? ""} onConfirm={() => run(async () => { if (!deleteDish()) return; await deleteMealDishById(deleteDish()!.id); setDeleteDish(null); await refetchMenu(); }, t("common.deleted"))} />286 <ConfirmDialog open={deleteDish() !== null} onOpenChange={(open) => !open && setDeleteDish(null)} title={t("meals.deleteDish")} variant="destructive" summary={deleteDish()?.name ?? ""} onConfirm={() => run(async () => { if (!deleteDish()) return; await deleteMealDishById(deleteDish()!.id); setDeleteDish(null); await refetchMenu(); }, t("common.deleted"))} />
287 287
288- <SidePanel open={showMenuEdit()} onOpenChange={setShowMenuEdit} title={t("meals.editMenu")} description={`${current().date} · ${current().slot}`}>288+ <SidePanel guardUnsaved open={showMenuEdit()} onOpenChange={setShowMenuEdit} title={t("meals.editMenu")} description={`${current().date} · ${current().slot}`}>
289 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void run(async () => { await patchMealMenuById(id(), { capacity: capacity() ? Number(capacity()) : null }); setShowMenuEdit(false); await refetchMenu(); }); }}><div class="space-y-1.5"><Label for="menu-capacity">{t("meals.capacity")}</Label><Input id="menu-capacity" type="number" min={0} max={limits()?.meal.max_menu_capacity} value={capacity()} onInput={(e) => setCapacity(e.currentTarget.value)} /></div><Button type="submit" disabled={pending()}>{t("common.save")}</Button></form>289 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void run(async () => { await patchMealMenuById(id(), { capacity: capacity() ? Number(capacity()) : null }); setShowMenuEdit(false); await refetchMenu(); }); }}><div class="space-y-1.5"><Label for="menu-capacity">{t("meals.capacity")}</Label><Input id="menu-capacity" type="number" min={0} max={limits()?.meal.max_menu_capacity} value={capacity()} onInput={(e) => setCapacity(e.currentTarget.value)} /></div><Button type="submit" disabled={pending()}>{t("common.save")}</Button></form>
290 </SidePanel>290 </SidePanel>
291- <SidePanel open={showDishForm()} onOpenChange={setShowDishForm} title={editingDish() ? t("meals.editDish") : t("meals.addDish")} description={`${current().date} · ${current().slot}`}>291+ <SidePanel guardUnsaved open={showDishForm()} onOpenChange={setShowDishForm} title={editingDish() ? t("meals.editDish") : t("meals.addDish")} description={`${current().date} · ${current().slot}`}>
292 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void run(async () => { const body = { name: dishName().trim(), description: dishDescription().trim() || null, price_minor: Math.round(Number(dishPrice()) * 100), tags: dishTags() }; if (editingDish()) await patchMealDishById(editingDish()!.id, body); else await postMealDish(id(), body); setShowDishForm(false); await refetchMenu(); }); }}>292 <form class="space-y-4" onSubmit={(e) => { e.preventDefault(); void run(async () => { const body = { name: dishName().trim(), description: dishDescription().trim() || null, price_minor: Math.round(Number(dishPrice()) * 100), tags: dishTags() }; if (editingDish()) await patchMealDishById(editingDish()!.id, body); else await postMealDish(id(), body); setShowDishForm(false); await refetchMenu(); }); }}>
293 <div class="space-y-1.5"><Label for="dish-name">{t("meals.dishName")}</Label><Input id="dish-name" required maxlength={limits()?.meal.max_dish_name_len} value={dishName()} onInput={(e) => setDishName(e.currentTarget.value)} /></div>293 <div class="space-y-1.5"><Label for="dish-name">{t("meals.dishName")}</Label><Input id="dish-name" required maxlength={limits()?.meal.max_dish_name_len} value={dishName()} onInput={(e) => setDishName(e.currentTarget.value)} /></div>
294 <div class="space-y-1.5"><Label for="dish-description">{t("form.description")}</Label><Textarea id="dish-description" maxlength={limits()?.meal.max_dish_description_len} value={dishDescription()} onInput={(e) => setDishDescription(e.currentTarget.value)} /></div>294 <div class="space-y-1.5"><Label for="dish-description">{t("form.description")}</Label><Textarea id="dish-description" maxlength={limits()?.meal.max_dish_description_len} value={dishDescription()} onInput={(e) => setDishDescription(e.currentTarget.value)} /></div>
src/pages/payments-page.tsxmodified+3 -3
@@ -850,7 +850,7 @@ function PaymentsContent() {
850 </SidePanel>850 </SidePanel>
851 851
852 {/* ---------------- Collect payment panel ---------------- */}852 {/* ---------------- Collect payment panel ---------------- */}
853- <SidePanel853+ <SidePanel guardUnsaved
854 open={collectEntry() != null}854 open={collectEntry() != null}
855 onOpenChange={(open) => { if (!open) setCollectEntry(null); }}855 onOpenChange={(open) => { if (!open) setCollectEntry(null); }}
856 title={t("payments.collectFrom")}856 title={t("payments.collectFrom")}
@@ -889,7 +889,7 @@ function PaymentsContent() {
889 </SidePanel>889 </SidePanel>
890 890
891 {/* ---------------- Correction panel (refund / reverse) ---------------- */}891 {/* ---------------- Correction panel (refund / reverse) ---------------- */}
892- <SidePanel892+ <SidePanel guardUnsaved
893 open={lineAction() != null}893 open={lineAction() != null}
894 onOpenChange={(open) => { if (!open) setLineAction(null); }}894 onOpenChange={(open) => { if (!open) setLineAction(null); }}
895 title={lineAction()?.kind === "refund" ? t("payments.recordRefund") : t("payments.reverse")}895 title={lineAction()?.kind === "refund" ? t("payments.recordRefund") : t("payments.reverse")}
@@ -917,7 +917,7 @@ function PaymentsContent() {
917 </SidePanel>917 </SidePanel>
918 918
919 {/* ---------------- Plan create / edit ---------------- */}919 {/* ---------------- Plan create / edit ---------------- */}
920- <SidePanel open={panelOpen()} onOpenChange={(open) => { setPanelOpen(open); if (!open) resetPlanForm(); }} title={editing() ? t("payments.editPlan") : t("payments.createPlan")} description={t("payments.subtitle")}>920+ <SidePanel guardUnsaved open={panelOpen()} onOpenChange={(open) => { setPanelOpen(open); if (!open) resetPlanForm(); }} title={editing() ? t("payments.editPlan") : t("payments.createPlan")} description={t("payments.subtitle")}>
921 <form class="space-y-4" onSubmit={savePlan}>921 <form class="space-y-4" onSubmit={savePlan}>
922 <Show when={error()}>922 <Show when={error()}>
923 <Alert variant="destructive">{error()}</Alert>923 <Alert variant="destructive">{error()}</Alert>
src/pages/profile-page.tsxmodified+1 -1
@@ -220,7 +220,7 @@ function ProfileContent() {
220 courseTotal={p().stats.courses}220 courseTotal={p().stats.courses}
221 />221 />
222 222
223- <SidePanel open={editing()} onOpenChange={setEditing} title={t("profile.edit")}>223+ <SidePanel guardUnsaved open={editing()} onOpenChange={setEditing} title={t("profile.edit")}>
224 <Show when={auth.user()}>224 <Show when={auth.user()}>
225 {(u) => (225 {(u) => (
226 <ProfileForm226 <ProfileForm
src/pages/question-bank-page.tsxmodified+1 -1
@@ -283,7 +283,7 @@ function QuestionBankContent() {
283 </TabsContent>283 </TabsContent>
284 </Tabs>284 </Tabs>
285 285
286- <SidePanel286+ <SidePanel guardUnsaved
287 open={createOpen() || editing() != null}287 open={createOpen() || editing() != null}
288 onOpenChange={(open) => {288 onOpenChange={(open) => {
289 if (!open) {289 if (!open) {
src/pages/staff-work-page.tsxmodified+1 -1
@@ -356,7 +356,7 @@ function StaffWorkContent() {
356 </Show>356 </Show>
357 </SidePanel>357 </SidePanel>
358 358
359- <SidePanel359+ <SidePanel guardUnsaved
360 open={editTarget() != null}360 open={editTarget() != null}
361 onOpenChange={(open) => {361 onOpenChange={(open) => {
362 if (!open) {362 if (!open) {
src/pages/terms-page.tsxmodified+1 -1
@@ -251,7 +251,7 @@ function TermsContent() {
251 </Suspense>251 </Suspense>
252 </section>252 </section>
253 253
254- <SidePanel254+ <SidePanel guardUnsaved
255 open={panelOpen()}255 open={panelOpen()}
256 onOpenChange={(open) => {256 onOpenChange={(open) => {
257 setPanelOpen(open);257 setPanelOpen(open);
src/pages/whiteboards-page.tsxmodified+1 -1
@@ -254,7 +254,7 @@ function CreateBoardPanel(props: {
254 };254 };
255 255
256 return (256 return (
257- <SidePanel open={props.open} onOpenChange={props.onOpenChange} title={t("whiteboard.create")}>257+ <SidePanel guardUnsaved open={props.open} onOpenChange={props.onOpenChange} title={t("whiteboard.create")}>
258 <div class="space-y-4">258 <div class="space-y-4">
259 <Show when={error()}>259 <Show when={error()}>
260 <ErrorAlert message={error()} />260 <ErrorAlert message={error()} />