mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
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.
This commit is contained in:
1 parent
a062610895
commit
ec82ad3a93
13 files changed
+325
-16
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
buildChecklist,
|
||||
checklistOrderFromNeeds,
|
||||
checklistProgress,
|
||||
CHECKLIST_BASE_ITEM_IDS,
|
||||
CHECKLIST_ITEM_IDS,
|
||||
isProfileComplete,
|
||||
shouldShowChecklist,
|
||||
@@ -52,6 +53,7 @@ function inputs(
|
||||
notificationsConfigured: false,
|
||||
insightsConfigured: false,
|
||||
dismissedIds: new Set<ChecklistItemId>(),
|
||||
upcomingVisitCount: 0,
|
||||
onboarding: null,
|
||||
...overrides,
|
||||
};
|
||||
@@ -141,6 +143,51 @@ describe("buildChecklist", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("the visit row (v1.39 C2)", () => {
|
||||
it("exists only for an answer that named a visit within a month", () => {
|
||||
const asked = buildChecklist(
|
||||
inputs({ onboarding: onboardingState({}, { visit: "within-a-month" }) }),
|
||||
);
|
||||
expect(asked.map((i) => i.id)).toContain("visit");
|
||||
expect(asked.find((i) => i.id === "visit")).toMatchObject({
|
||||
done: false,
|
||||
href: "/checkups",
|
||||
});
|
||||
const later = buildChecklist(
|
||||
inputs({ onboarding: onboardingState({}, { visit: "later" }) }),
|
||||
);
|
||||
expect(later.map((i) => i.id)).not.toContain("visit");
|
||||
expect(buildChecklist(inputs()).map((i) => i.id)).not.toContain("visit");
|
||||
});
|
||||
|
||||
it("is done once a visit is on the calendar", () => {
|
||||
const items = buildChecklist(
|
||||
inputs({
|
||||
onboarding: onboardingState({}, { visit: "within-a-month" }),
|
||||
upcomingVisitCount: 1,
|
||||
}),
|
||||
);
|
||||
expect(items.find((i) => i.id === "visit")?.done).toBe(true);
|
||||
});
|
||||
|
||||
it("is promoted by the answers like the other needs-shaped rows", () => {
|
||||
expect(
|
||||
checklistOrderFromNeeds({
|
||||
...emptyOnboardingNeeds(),
|
||||
visit: "within-a-month",
|
||||
}),
|
||||
).toEqual([
|
||||
"profile",
|
||||
"visit",
|
||||
"measurement",
|
||||
"medication",
|
||||
"dataSource",
|
||||
"notifications",
|
||||
"insights",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("visibleChecklist + checklistProgress", () => {
|
||||
it("hides per-item dismissed rows from the visible list", () => {
|
||||
const items = buildChecklist(
|
||||
@@ -180,6 +227,7 @@ describe("visibleChecklist + checklistProgress", () => {
|
||||
notificationsConfigured: false,
|
||||
insightsConfigured: false,
|
||||
dismissedIds: new Set(),
|
||||
upcomingVisitCount: 0,
|
||||
});
|
||||
const progress = checklistProgress(items);
|
||||
expect(progress.percent).toBe(0);
|
||||
@@ -332,7 +380,7 @@ describe("checklistOrderFromNeeds", () => {
|
||||
describe("buildChecklist, ordered by the setup answers", () => {
|
||||
it("keeps the fixed order for a record that never entered the flow", () => {
|
||||
expect(buildChecklist(inputs()).map((i) => i.id)).toEqual([
|
||||
...CHECKLIST_ITEM_IDS,
|
||||
...CHECKLIST_BASE_ITEM_IDS,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -347,7 +395,7 @@ describe("buildChecklist, ordered by the setup answers", () => {
|
||||
);
|
||||
// Re-ordering the dashboard under somebody mid-question would be movement
|
||||
// they did not ask for.
|
||||
expect(items.map((i) => i.id)).toEqual([...CHECKLIST_ITEM_IDS]);
|
||||
expect(items.map((i) => i.id)).toEqual([...CHECKLIST_BASE_ITEM_IDS]);
|
||||
});
|
||||
|
||||
it("orders the rows from the answers once the flow is confirmed", () => {
|
||||
@@ -365,7 +413,7 @@ describe("buildChecklist, ordered by the setup answers", () => {
|
||||
"dataSource",
|
||||
]);
|
||||
expect([...items.map((i) => i.id)].sort()).toEqual(
|
||||
[...CHECKLIST_ITEM_IDS].sort(),
|
||||
[...CHECKLIST_BASE_ITEM_IDS].sort(),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -20,10 +20,17 @@ export const CHECKLIST_ITEM_IDS = [
|
||||
"dataSource",
|
||||
"notifications",
|
||||
"insights",
|
||||
// v1.39 (C2) — present only for an answer that named a visit within a
|
||||
// month (design spec §After the flow: "prepare the visit").
|
||||
"visit",
|
||||
] as const;
|
||||
|
||||
export type ChecklistItemId = (typeof CHECKLIST_ITEM_IDS)[number];
|
||||
|
||||
/** The rows every record has; the visit row joins only when asked for. */
|
||||
export const CHECKLIST_BASE_ITEM_IDS: readonly ChecklistItemId[] =
|
||||
CHECKLIST_ITEM_IDS.filter((id) => id !== "visit");
|
||||
|
||||
export interface ChecklistItem {
|
||||
id: ChecklistItemId;
|
||||
done: boolean;
|
||||
@@ -71,6 +78,12 @@ export interface ChecklistInputs {
|
||||
insightsConfigured: boolean;
|
||||
/** Dismissed item ids (per-item localStorage state). */
|
||||
dismissedIds: ReadonlySet<ChecklistItemId>;
|
||||
/**
|
||||
* v1.39 (C2) — visits booked from today on, for the "prepare the visit"
|
||||
* row. Read only while the row can exist, so a caller that never asked the
|
||||
* question passes zero.
|
||||
*/
|
||||
upcomingVisitCount: number;
|
||||
/**
|
||||
* v1.39 (C1) — the needs-based setup state from `GET /api/auth/me`, or null
|
||||
* for a record that never entered the flow.
|
||||
@@ -112,6 +125,7 @@ export function checklistOrderFromNeeds(
|
||||
promote("dataSource");
|
||||
}
|
||||
if (needs.areas.length > 0) promote("measurement");
|
||||
if (needs.visit === "within-a-month") promote("visit");
|
||||
|
||||
return [
|
||||
"profile",
|
||||
@@ -125,8 +139,8 @@ export function checklistOrderFromNeeds(
|
||||
/**
|
||||
* Compute the ordered checklist for the dashboard hero. Stable order:
|
||||
* profile → measurement → medication → dataSource → notifications →
|
||||
* insights. Each item carries the deep-link the row's CTA should
|
||||
* navigate to.
|
||||
* insights, plus the visit row for an answer that named one. Each item
|
||||
* carries the deep-link the row's CTA should navigate to.
|
||||
*/
|
||||
export function buildChecklist(inputs: ChecklistInputs): ChecklistItem[] {
|
||||
const profileDone = isProfileComplete(inputs.profile);
|
||||
@@ -169,6 +183,16 @@ export function buildChecklist(inputs: ChecklistInputs): ChecklistItem[] {
|
||||
},
|
||||
];
|
||||
if (!inputs.onboarding) return items;
|
||||
// The visit row exists only for the answer that asked for it; every other
|
||||
// record keeps the six rows it had. Done once a visit is on the calendar.
|
||||
if (inputs.onboarding.needs.visit === "within-a-month") {
|
||||
items.push({
|
||||
id: "visit",
|
||||
done: inputs.upcomingVisitCount >= 1,
|
||||
href: "/checkups",
|
||||
dismissed: inputs.dismissedIds.has("visit"),
|
||||
});
|
||||
}
|
||||
// Ordered from the answers only once the flow has been confirmed: before
|
||||
// that the answers are still being given, and re-ordering the dashboard
|
||||
// under someone mid-question would be movement they did not ask for.
|
||||
|
||||
@@ -24,4 +24,13 @@ export const onboardingKeys = {
|
||||
*/
|
||||
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,
|
||||
};
|
||||
Reference in new issue
Block a user