feat: add shared overview and harden frontend session state (#407)

This commit is contained in:
Daniel Volz
2026-03-10 06:26:03 +01:00
committed by GitHub
parent 733fe2f38a
commit 105eb7bc0d
37 changed files with 3281 additions and 1138 deletions
+9
View File
@@ -8,6 +8,7 @@ export interface UseMedicationsReturn {
saving: boolean;
setSaving: React.Dispatch<React.SetStateAction<boolean>>;
uploadingImage: boolean;
clearMedicationsState: () => void;
loadMeds: () => void;
deleteMed: (id: number, editingId: number | null, resetForm: () => void) => Promise<void>;
uploadMedImage: (medId: number, file: File) => Promise<void>;
@@ -20,6 +21,13 @@ export function useMedications(): UseMedicationsReturn {
const [saving, setSaving] = useState(false);
const [uploadingImage, setUploadingImage] = useState(false);
const clearMedicationsState = useCallback(() => {
setMeds([]);
setLoading(false);
setSaving(false);
setUploadingImage(false);
}, []);
const loadMeds = useCallback(() => {
setLoading(true);
fetch("/api/medications?includeObsolete=true", { credentials: "include" })
@@ -96,6 +104,7 @@ export function useMedications(): UseMedicationsReturn {
saving,
setSaving,
uploadingImage,
clearMedicationsState,
loadMeds,
deleteMed,
uploadMedImage,