mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(medications): refetch the daily reads after the track-intake switch
This commit is contained in:
1 parent
2311f9b47d
commit
04a683ae07
2 files changed
+11
-1
No files matched your search
@@ -248,6 +248,9 @@ const PINNED_AFFORDANCES: Record<
|
||||
"src/components/medications/sections/inventory-dialogs.tsx": {
|
||||
"toast.success": 3,
|
||||
},
|
||||
"src/components/medications/sections/intake-tracking-section.tsx": {
|
||||
"toast.success": 1,
|
||||
},
|
||||
"src/components/medications/sections/inventory-section.tsx": {
|
||||
"toast.success": 1,
|
||||
},
|
||||
|
||||
@@ -16,7 +16,11 @@ import { toast } from "sonner";
|
||||
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { invalidateKeys, medicationDependentKeys } from "@/lib/query-keys";
|
||||
import {
|
||||
invalidateKeys,
|
||||
medicationDependentKeys,
|
||||
refetchInactiveDailyReads,
|
||||
} from "@/lib/query-keys";
|
||||
import { apiPut } from "@/lib/api/api-fetch";
|
||||
|
||||
const SWITCH_ID = "medication-detail-track-intake-switch";
|
||||
@@ -43,6 +47,9 @@ export function IntakeTrackingBody({
|
||||
try {
|
||||
await apiPut(`/api/medications/${medicationId}`, { trackIntake: next });
|
||||
await invalidateKeys(queryClient, medicationDependentKeys);
|
||||
// The doses card and the Today digest read this medication's due
|
||||
// state; they are usually unmounted here, so refetch them now.
|
||||
await refetchInactiveDailyReads(queryClient);
|
||||
toast.success(
|
||||
next
|
||||
? t("medications.trackIntake.enabledToast")
|
||||
|
||||
Reference in new issue
Block a user