mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
fix(forms): keep one Idempotency-Key for the remaining create forms
A screening, an illness episode, a life event, a symptom, a custom metric or an address-book entry created on a weak signal could be stored twice: the POST committed, the answer missed the timeout, and the second tap went out under a new key. Their routes already honour the key; the forms now post through useIdempotentPost like the other create forms, so the retry replays the first answer. The screening's save moves into a small hook beside MentalWellbeing, which sat at the function-size cap and now drops below it; the custom metric form's create-or-update call moves into one as well.
This commit is contained in:
1 parent
4485dfb3a9
commit
e68041a3af
8 files changed
+102
-38
No files matched your search
@@ -11,6 +11,7 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiDelete, apiGetList, apiPatch, apiPost } from "@/lib/api/api-fetch";
|
||||
import { useIdempotentPost } from "@/lib/api/use-idempotent-post";
|
||||
import {
|
||||
encounterDependentKeys,
|
||||
invalidateKeys,
|
||||
@@ -70,10 +71,11 @@ export function usePractitionerMutations() {
|
||||
refetchInactiveDailyReads(qc),
|
||||
]);
|
||||
|
||||
// One key for as long as the sheet that mounts this is open.
|
||||
const post = useIdempotentPost();
|
||||
const create = useMutation({
|
||||
mutationKey: queryKeys.practitionerCreate(),
|
||||
mutationFn: (body: PractitionerWriteBody) =>
|
||||
apiPost<Practitioner>(BASE, body),
|
||||
mutationFn: (body: PractitionerWriteBody) => post<Practitioner>(BASE, body),
|
||||
onSuccess: invalidate,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user