fix(visits): keep the appointment rail action's wire tokens for the shipped app

The shipped iOS app routes the rail by intent and resolves the label
from its own catalogue; a new `visit.view` intent would leave its tap on
an appointment inert. The upcoming-visit action keeps `checkup.view`
and `daily.action.viewCheckups` on the wire and only its `href` moves
to the visit. The web card names what that link opens: "View
appointment", or "View appointments" for the visits list.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 12:38:08 +02:00
1 parent 99fec79177
commit 2914832ed8
5 files changed
+73 -20

No files matched your search

@@ -161,6 +161,37 @@ describe("<PriorityCard>", () => {
expect(html).toContain("View check-ups");
});
// An appointment keeps the check-up label on the wire for the shipped iOS
// app; the web names what the link opens. The check-up item above is the
// negative control.
it("names an appointment's action for the visit it opens", () => {
const action = (href: string) => ({
labelKey: "daily.action.viewCheckups",
intent: "checkup.view",
href,
});
const one = render(
<PriorityCard
item={item({
kind: "upcoming_visit",
actions: [action("/checkups?visit=v1")],
})}
/>,
);
expect(one).toContain("View appointment");
expect(one).not.toContain("View check-ups");
expect(one).toContain('href="/checkups?visit=v1"');
const several = render(
<PriorityCard
item={item({
kind: "upcoming_visit",
actions: [action("/checkups?view=visits")],
})}
/>,
);
expect(several).toContain("View appointments");
});
describe("dismiss affordance — observational kinds only", () => {
const DISMISSIBLE: PriorityItemKind[] = [
"milestone",
+20 -1
View File
@@ -36,6 +36,7 @@ import { Card, CardContent } from "@/components/ui/card";
import { TileHeader } from "@/components/insights/tile-header";
import { ProseBlocks } from "@/components/insights/prose-blocks";
import { Button, buttonVariants } from "@/components/ui/button";
import { VISITS_PATH } from "@/lib/encounters/visit-links";
import { useTranslations } from "@/lib/i18n/context";
import { cn } from "@/lib/utils";
import {
@@ -205,7 +206,7 @@ export function PriorityCard({
<ActionLink
key={action.intent}
href={action.href}
label={t(action.labelKey)}
label={t(actionLabelKey(item, action))}
/>
) : onAction ? (
<ActionButton
@@ -225,6 +226,24 @@ export function PriorityCard({
}
/** A navigation action. Always offered — reading is never delegated away. */
/**
* The label key a web card shows for an action.
*
* The server's `labelKey`, except on an appointment: that item still carries
* the check-up item's label on the wire ("View check-ups"), because the
* shipped iOS app resolves the label and routes the intent it already knows.
* Its `href` already opens the visit, so the web names what it opens.
*/
export function actionLabelKey(
item: Pick<PriorityItem, "kind">,
action: Pick<PriorityItemAction, "labelKey" | "href">,
): string {
if (item.kind !== "upcoming_visit" || !action.href) return action.labelKey;
return action.href === VISITS_PATH
? "daily.action.viewAppointments"
: "daily.action.viewAppointment";
}
function ActionLink({ href, label }: { href: string; label: string }) {
return (
<Link
+2 -2
View File
@@ -30,8 +30,8 @@
* stands in its place — not an alarming empty card.
*
* Every `PriorityItem` action carries an `href` (dose.log → /medications,
* sync.reconnect → /settings/integrations, checkup.view → /checkups,
* visit.view → the visit on the checkups page's visits tab), so
* sync.reconnect → /settings/integrations, checkup.view → /checkups, or the
* visit itself on an upcoming_visit item), so
* `PriorityCard` wires each tap as a `<Link>` to its existing destination
* by construction; S2 invents no new backend action.
*