Files
HealthLog/src/lib/query-keys/onboarding.ts
T
Marc-André Bombeck ec82ad3a93 Carry the setup answers into the checklist, Settings and the module pages
The getting-started checklist reads the answers: a visit named within a
month adds a "prepare the visit" row that is done once one is on the
calendar, and the data-source row names the wearable that was chosen.
Its per-browser state moves to one module so the done screen, the skip
and Settings write the same keys.

Settings → Account gains the two ways back in: "Set up again" through
the restart route, which resets the ledger, keeps the answers as
prefill and touches no module; and "Show the checklist again", which
forgets what this browser hid.

A page whose module is off now answers with the shared notice and the
one action that helps, in one place for every module page: the shell
maps the route to the module through the navigation model's own gate,
so a page and its nav entry cannot disagree about which switch they
follow. And the tour's two dead stops get their anchors on the
integrations and health-record group headings.
2026-09-10 15:41:06 +02:00

37 lines
1.9 KiB
TypeScript

/**
* Query keys — the needs-based setup flow (v1.39 C2).
* Part of the centralized factory; aggregated in `./index.ts`.
*
* The flow has no read of its own: its state rides `GET /api/auth/me` as
* `onboarding`, so every screen reads `queryKeys.authMe()` and every write
* below invalidates it. What lives here are the mutation keys, one per
* endpoint, so a screen that persists an answer and a settings card that
* restarts the flow cannot collide on an anonymous mutation.
*/
export const onboardingKeys = {
/** `PATCH /api/onboarding/answers` — one step, answered or skipped. */
onboardingAnswerMutation: () => ["onboarding", "answer"] as const,
/** `POST /api/onboarding/complete` — the confirm screen, and "skip for now". */
onboardingCompleteMutation: () => ["onboarding", "complete"] as const,
/** `POST /api/onboarding/restart` — "Set up again", from Settings. */
onboardingRestartMutation: () => ["onboarding", "restart"] as const,
/** `POST /api/onboarding/disclaimer` — the one-time acknowledgment. */
onboardingDisclaimerMutation: () => ["onboarding", "disclaimer"] as const,
/**
* The latest reading of one type, read back after the first-result step
* logged it so the screen can show the value on its tile. Rides under the
* `["measurements"]` prefix so `measurementDependentKeys` evicts it.
*/
onboardingLatestReading: (type: string) =>
["measurements", "onboarding-latest", type] as const,
/**
* The upcoming-visit count the checklist's "prepare the visit" row reads
* off the visits list's meta. Its own key under the `["encounters"]`
* prefix: the list surfaces cache the rows under `encounters()`, and a
* second `queryFn` shape on the same key would poison that cell, while
* the prefix still lets `encounterDependentKeys` evict this one.
*/
onboardingUpcomingVisits: () =>
["encounters", "onboarding-upcoming"] as const,
};