+ <>
+
+
+ {hideHeader ? (
+
+ {title}
+ {description ? (
+ {description}
+ ) : null}
+
+ ) : (
+
+ {headerAction ? (
+ <>
+
+
+ {title}
+
+ {description ? (
+
+ {description}
+
+ ) : null}
+
+ {headerAction}
+ >
+ ) : (
+ <>
{title}
@@ -230,160 +335,154 @@ export function ResponsiveSheet({
{description}
) : null}
+ >
+ )}
+
+ )}
+
+ {children}
+
+ {footer ? (
+
+ {footer}
+
+ ) : null}
+
+
+ {discard}
+ >
+ );
+ }
+
+ return (
+ <>
+
+ {discard}
+ >
);
}
diff --git a/src/components/vaccinations/vaccination-sheet.tsx b/src/components/vaccinations/vaccination-sheet.tsx
index a63972299..dffedee21 100644
--- a/src/components/vaccinations/vaccination-sheet.tsx
+++ b/src/components/vaccinations/vaccination-sheet.tsx
@@ -76,9 +76,10 @@ export function VaccinationSheet({
const detail = useVaccination(vaccination?.id ?? null);
const [confirmingDelete, setConfirmingDelete] = useState(false);
// Seeded once at mount; the caller remounts on every open by varying `key`.
- const [draft, setDraft] = useState
(() =>
+ const [seed] = useState(() =>
vaccination ? draftFromVaccination(vaccination) : emptyDraft(),
);
+ const [draft, setDraft] = useState(seed);
const [error, setError] = useState(null);
const isEdit = vaccination !== null;
@@ -111,6 +112,7 @@ export function VaccinationSheet({
(null);
- const [confirmDiscardOpen, setConfirmDiscardOpen] = useState(false);
const editDirty = useRef(false);
const handleDirtyChange = useCallback((dirty: boolean) => {
editDirty.current = dirty;
}, []);
- function handleOpenChange(next: boolean) {
- if (next) return onOpenChange(true);
- if (edit ? editDirty.current : sheetBodyHasUnsavedInput()) {
- setConfirmDiscardOpen(true);
- return;
- }
- onOpenChange(false);
- }
-
return (
- <>
- }
- >
- {open && (
- onOpenChange(false)}
- onCancel={() => onOpenChange(false)}
- footerSlot={footerEl}
- edit={edit}
- onDirtyChange={edit ? handleDirtyChange : undefined}
- />
- )}
-
-
-
-
-
- {t("dashboard.quickEntryDiscard.title")}
-
-
- {t("dashboard.quickEntryDiscard.description")}
-
-
-
-
- {t("dashboard.quickEntryDiscard.cancel")}
-
- {
- setConfirmDiscardOpen(false);
- onOpenChange(false);
- }}
- >
- {t("dashboard.quickEntryDiscard.confirm")}
-
-
-
-
- >
+ editDirty.current : sheetBodyHasUnsavedInput}
+ title={t(
+ edit
+ ? "insights.workouts.manual.editTitle"
+ : "insights.workouts.manual.sheetTitle",
+ )}
+ description={t("insights.workouts.manual.sheetDescription")}
+ footer={}
+ >
+ {open && (
+ onOpenChange(false)}
+ onCancel={() => onOpenChange(false)}
+ footerSlot={footerEl}
+ edit={edit}
+ onDirtyChange={edit ? handleDirtyChange : undefined}
+ />
+ )}
+
);
}