create-ailk 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +21 -3
  2. package/component-catalog.json +12 -1
  3. package/component-catalog.md +6 -5
  4. package/dist/export-content.d.ts +6 -3
  5. package/dist/export-content.js +82 -11
  6. package/dist/lib/env-catalog.js +4 -0
  7. package/dist/lib/import-mdx.d.ts +111 -0
  8. package/dist/lib/import-mdx.js +648 -46
  9. package/dist/migrate-content.d.ts +3 -1
  10. package/dist/migrate-content.js +52 -1
  11. package/dist/seed-flows.d.ts +1 -1
  12. package/dist/seed-flows.js +9 -4
  13. package/dist/surfaces.js +1 -0
  14. package/package.json +3 -3
  15. package/templates/apps/api/.env.example +11 -0
  16. package/templates/apps/api/CLAUDE.md +7 -5
  17. package/templates/apps/api/src/lib/__mocks__/prisma.ts +13 -0
  18. package/templates/apps/mcp/CLAUDE.md +4 -2
  19. package/templates/apps/web/CLAUDE.md +4 -1
  20. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +28 -0
  21. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +94 -0
  22. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +77 -0
  23. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +79 -14
  24. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +7 -0
  25. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +7 -0
  26. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +7 -0
  27. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +21 -0
  28. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +15 -9
  29. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +38 -105
  30. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +72 -58
  31. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +249 -0
  32. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +164 -20
  33. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +269 -0
  34. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +179 -0
  35. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +108 -40
  36. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +153 -0
  37. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +151 -0
  38. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +1 -1
  39. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +3 -20
  40. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +2 -9
  41. package/templates/apps/web/auth.ts +22 -6
  42. package/templates/apps/web/lib/__tests__/account-config.test.ts +69 -0
  43. package/templates/apps/web/lib/__tests__/auth-email.test.ts +99 -1
  44. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +20 -0
  45. package/templates/apps/web/lib/account-config.ts +52 -14
  46. package/templates/apps/web/lib/auth-email.ts +87 -5
  47. package/templates/apps/web/lib/mcp-oauth.ts +49 -6
  48. package/templates/apps/web/lib/telemetry-scrub.ts +6 -0
  49. package/templates/apps/web/messages/en.json +26 -1
  50. package/templates/database/seed.ts +7 -7
  51. package/versions.json +48 -48
  52. package/templates/apps/web/app/[locale]/thanks/[slug]/AccountInviteLink.tsx +0 -89
  53. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/AccountInviteLink.test.tsx +0 -104
@@ -0,0 +1,249 @@
1
+ /**
2
+ * A magnet Lead's confirm page and action (#10826, spec
3
+ * docs/specs/10826-the-four-conversions-as-completion-spec.md D5; AC-2).
4
+ *
5
+ * The page: `?lead=L&verify=N` renders one confirm button and calls no API
6
+ * while it renders; `?confirmed=1` and `?error=…` render their cards.
7
+ * The action: every bound argument is re-checked before any API call; the
8
+ * limit and the bot check run first; the API's answer picks the redirect,
9
+ * which is always same-site and never carries the nonce.
10
+ */
11
+ import { render, screen } from "@testing-library/react";
12
+
13
+ import en from "../../../../../messages/en.json";
14
+
15
+ const mockRedirect = jest.fn((url: string) => {
16
+ throw new Error(`REDIRECT ${url}`);
17
+ });
18
+ const mockNotFound = jest.fn(() => {
19
+ throw new Error("NOT_FOUND");
20
+ });
21
+ jest.mock("next/navigation", () => ({
22
+ redirect: (url: string) => mockRedirect(url),
23
+ notFound: () => mockNotFound(),
24
+ }));
25
+
26
+ const mockHeaders = jest.fn(
27
+ async () => new Headers({ "x-forwarded-for": "203.0.113.9" }),
28
+ );
29
+ jest.mock("next/headers", () => ({
30
+ headers: () => mockHeaders(),
31
+ }));
32
+
33
+ const mockRunBotCheck = jest.fn();
34
+ // eslint-disable-next-line no-restricted-syntax -- BotID is an external service boundary; lib/bot-check.ts is its one wrapper.
35
+ jest.mock("../../../../../lib/bot-check", () => ({
36
+ runBotCheck: (...args: unknown[]) => mockRunBotCheck(...args),
37
+ }));
38
+
39
+ const mockVerifyLead = jest.fn();
40
+ jest.mock("@working-theory/api-client", () => ({
41
+ flows: { verifyLead: (...args: unknown[]) => mockVerifyLead(...args) },
42
+ }));
43
+
44
+ import { __resetRateLimit } from "../../../../../src/lib/rate-limit";
45
+ import FlowVerifyPage from "../verify/page";
46
+ import { confirmLeadEmailAction } from "../verify.actions";
47
+
48
+ const SLUG = "growth-check";
49
+ const LEAD = "lead_01920000-1082-7000-8000-000000000001";
50
+ const NONCE = "N".repeat(43);
51
+
52
+ async function renderPage(
53
+ query: Record<string, string>,
54
+ slug = SLUG,
55
+ ): Promise<void> {
56
+ render(
57
+ await FlowVerifyPage({
58
+ params: Promise.resolve({ locale: "en", slug }),
59
+ searchParams: Promise.resolve(query),
60
+ }),
61
+ );
62
+ }
63
+
64
+ /** Run the action; answer the redirect URL, asserting it never carries the nonce. */
65
+ async function redirectOf(
66
+ args: [slug?: string, leadId?: string, nonce?: string, locale?: string] = [],
67
+ ): Promise<string> {
68
+ const [slug = SLUG, leadId = LEAD, nonce = NONCE, locale = "en"] = args;
69
+ await expect(
70
+ confirmLeadEmailAction(slug, leadId, nonce, locale),
71
+ ).rejects.toThrow(/^REDIRECT /);
72
+ const url = mockRedirect.mock.calls.at(-1)![0];
73
+ if (nonce.length > 0) expect(url).not.toContain(nonce);
74
+ return url;
75
+ }
76
+
77
+ const answer = (body: Record<string, unknown>) =>
78
+ mockVerifyLead.mockResolvedValue({ ok: true, body });
79
+
80
+ beforeEach(() => {
81
+ jest.clearAllMocks();
82
+ __resetRateLimit();
83
+ mockRunBotCheck.mockResolvedValue("pass");
84
+ answer({ outcome: "verified", landing: null });
85
+ });
86
+
87
+ describe("the confirm page (#10826 D5)", () => {
88
+ it("renders one confirm button on ?lead=&verify= and calls no API while rendering", async () => {
89
+ await renderPage({ lead: LEAD, verify: NONCE });
90
+ expect(screen.getByTestId("flow-verify-confirm")).toBeInTheDocument();
91
+ expect(screen.getByTestId("flow-verify-confirm-button")).toHaveTextContent(
92
+ en.flowVerify.confirmButton,
93
+ );
94
+ expect(mockVerifyLead).not.toHaveBeenCalled();
95
+ expect(mockRedirect).not.toHaveBeenCalled();
96
+ expect(document.body.innerHTML).not.toContain(NONCE);
97
+ });
98
+
99
+ it("renders the confirmed card on ?confirmed=1", async () => {
100
+ await renderPage({ confirmed: "1" });
101
+ expect(screen.getByTestId("flow-verify-confirmed")).toHaveTextContent(
102
+ en.flowVerify.confirmedHeading,
103
+ );
104
+ });
105
+
106
+ it.each([
107
+ ["?error=invalid", { error: "invalid" }],
108
+ ["no query", {}],
109
+ ["a lead id of the wrong shape", { lead: "x", verify: NONCE }],
110
+ ["a 257-character nonce", { lead: LEAD, verify: "N".repeat(257) }],
111
+ ])("renders the error card on %s", async (_label, query) => {
112
+ await renderPage(query);
113
+ expect(screen.getByTestId("flow-verify-error")).toHaveTextContent(
114
+ en.flowVerify.errorHeading,
115
+ );
116
+ expect(mockVerifyLead).not.toHaveBeenCalled();
117
+ });
118
+
119
+ it("verify wins over confirmed, and confirmed over error", async () => {
120
+ await renderPage({
121
+ lead: LEAD,
122
+ verify: NONCE,
123
+ confirmed: "1",
124
+ error: "invalid",
125
+ });
126
+ expect(screen.getByTestId("flow-verify-confirm")).toBeInTheDocument();
127
+ });
128
+
129
+ it("is a 404 for an unreadable slug", async () => {
130
+ await expect(
131
+ renderPage({ lead: LEAD, verify: NONCE }, "Bad_Slug"),
132
+ ).rejects.toThrow("NOT_FOUND");
133
+ });
134
+ });
135
+
136
+ describe("confirmLeadEmailAction (#10826 D5)", () => {
137
+ it("posts the bound Lead id and nonce, forwarding the visitor's address", async () => {
138
+ await redirectOf();
139
+ expect(mockVerifyLead).toHaveBeenCalledWith(
140
+ SLUG,
141
+ { leadId: LEAD, nonce: NONCE },
142
+ { headers: { "x-forwarded-for": "203.0.113.9" } },
143
+ );
144
+ });
145
+
146
+ it("redirects a verified lead-link confirm to its landing", async () => {
147
+ answer({ outcome: "verified", landing: "/pricing?plan=growth" });
148
+ expect(await redirectOf()).toBe("/pricing?plan=growth");
149
+ });
150
+
151
+ it("redirects to the confirmed card on already_verified with no landing", async () => {
152
+ answer({ outcome: "already_verified", landing: null });
153
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?confirmed=1`);
154
+ });
155
+
156
+ it("redirects a user magnet's verified Lead to the sign-up landing (accountInviteHref)", async () => {
157
+ answer({
158
+ outcome: "verified",
159
+ landing: null,
160
+ signUpEmail: "a+b@x.example",
161
+ });
162
+ expect(await redirectOf()).toBe(
163
+ "/sign-in?next=%2Faccount&email=a%2Bb%40x.example",
164
+ );
165
+ });
166
+
167
+ it.each([
168
+ "//evil.example",
169
+ "/\\evil.example",
170
+ "https://evil.example",
171
+ "/\t/evil.example",
172
+ "/\n/evil.example",
173
+ "/ok path",
174
+ "/ok\\..\\evil",
175
+ ])("never redirects to a landing of %s (SEC-10826-5)", async (landing) => {
176
+ answer({ outcome: "verified", landing });
177
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?confirmed=1`);
178
+ });
179
+
180
+ it.each([
181
+ ["expired", { ok: true, body: { outcome: "expired", landing: null } }],
182
+ ["invalid", { ok: true, body: { outcome: "invalid", landing: null } }],
183
+ ["a non-2xx", { ok: false, status: 503 }],
184
+ ])("redirects to the error card on %s", async (_label, res) => {
185
+ mockVerifyLead.mockResolvedValue(res);
186
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?error=invalid`);
187
+ });
188
+
189
+ it("redirects to the error card when the call throws", async () => {
190
+ mockVerifyLead.mockRejectedValue(new Error("boom"));
191
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?error=invalid`);
192
+ });
193
+
194
+ it.each(["bot", "unavailable"])(
195
+ "makes no API call when the bot check answers %s",
196
+ async (verdict) => {
197
+ mockRunBotCheck.mockResolvedValue(verdict);
198
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?error=invalid`);
199
+ expect(mockVerifyLead).not.toHaveBeenCalled();
200
+ },
201
+ );
202
+
203
+ it("makes no API call once the visitor's limit (5 per 10 minutes) is spent", async () => {
204
+ const vercel = process.env.VERCEL;
205
+ process.env.VERCEL = "1";
206
+ mockHeaders.mockImplementation(
207
+ async () => new Headers({ "x-vercel-forwarded-for": "203.0.113.9" }),
208
+ );
209
+ try {
210
+ for (let i = 0; i < 5; i++) await redirectOf();
211
+ mockVerifyLead.mockClear();
212
+ expect(await redirectOf()).toBe(`/flows/${SLUG}/verify?error=invalid`);
213
+ expect(mockVerifyLead).not.toHaveBeenCalled();
214
+ } finally {
215
+ if (vercel === undefined) delete process.env.VERCEL;
216
+ else process.env.VERCEL = vercel;
217
+ mockHeaders.mockImplementation(
218
+ async () => new Headers({ "x-forwarded-for": "203.0.113.9" }),
219
+ );
220
+ }
221
+ });
222
+
223
+ it.each([
224
+ ["a traversal slug", ["x/../../v1/other"], "/?error=invalid"],
225
+ [
226
+ "a locale that is not enabled",
227
+ [SLUG, LEAD, NONCE, "/evil.example"],
228
+ `/flows/${SLUG}/verify?error=invalid`,
229
+ ],
230
+ [
231
+ "a 257-character nonce",
232
+ [SLUG, LEAD, "N".repeat(257)],
233
+ `/flows/${SLUG}/verify?error=invalid`,
234
+ ],
235
+ ["an empty nonce", [SLUG, LEAD, ""], `/flows/${SLUG}/verify?error=invalid`],
236
+ [
237
+ "a Lead id of the wrong shape",
238
+ [SLUG, "lead_x"],
239
+ `/flows/${SLUG}/verify?error=invalid`,
240
+ ],
241
+ ] as const)(
242
+ "refuses %s with no API call (SEC-10826-6)",
243
+ async (_label, args, href) => {
244
+ expect(await redirectOf([...args])).toBe(href);
245
+ expect(mockVerifyLead).not.toHaveBeenCalled();
246
+ expect(mockRunBotCheck).not.toHaveBeenCalled();
247
+ },
248
+ );
249
+ });
@@ -13,7 +13,8 @@
13
13
  * Book-a-Call rail, §7.3); active region = the fits as
14
14
  * `RecommendationCard` (first fit `emphasis: "recommended"`, each with a
15
15
  * per-offer terminal — D2) + `PairingCard` when one matched; bar
16
- * `leading` = "Email me this plan" (D5).
16
+ * `leading` = "Email me this plan" (D5), absent when the served
17
+ * conversion is `none` (#10826).
17
18
  * - **checkout** — Get Started performs DESIGN §7.6's panel FLIP: the
18
19
  * email step takes the frame's first (side) slot — "fields left" — and
19
20
  * the configurable price card (#4865, D3) takes the second (active)
@@ -25,6 +26,14 @@
25
26
  * - **save** — the same email step with the save framing; the side panel
26
27
  * stays the safe-default card (FR4); success renders the saved state.
27
28
  *
29
+ * #10828 — a scored register's results open with the respondent's own
30
+ * score: the overall points out of the max and its Level name, then one
31
+ * `ScoreBar` per dimension in register order, then the cards. The score is
32
+ * `evaluateWaitlistScoring` over the decoded answers, run here as
33
+ * `recommend()` is; a Level is named by the register's `levels.names`, else
34
+ * "Level {n}". An unscored register (no scoring, or no points to score)
35
+ * renders the cards only.
36
+ *
28
37
  * The three frame regions keep their DOM identity across every transition
29
38
  * (#4806 FR7 — the frame is rendered once; only its slots change).
30
39
  *
@@ -54,6 +63,7 @@ import {
54
63
  Heading,
55
64
  PairingCard,
56
65
  RecommendationCard,
66
+ ScoreBar,
57
67
  Text,
58
68
  } from "@working-theory/ui";
59
69
  import {
@@ -61,16 +71,24 @@ import {
61
71
  type FlowSidePanelView,
62
72
  } from "@working-theory/ui-signal-collectors";
63
73
  import type {
74
+ FlowCompletion,
64
75
  FlowConfig,
65
76
  FlowSaveInput,
77
+ LookupKeyPeriod,
66
78
  RecommendRegister,
67
79
  WaitlistBillingPeriod,
68
80
  } from "@working-theory/validation";
69
- import { recommend, resolveLocalizedString } from "@working-theory/validation";
81
+ import {
82
+ evaluateWaitlistScoring,
83
+ flowRecommendRegister,
84
+ recommend,
85
+ resolveLocalizedString,
86
+ } from "@working-theory/validation";
70
87
  import { useTranslations } from "next-intl";
71
88
  import type { ReactElement, ReactNode } from "react";
72
89
  import { useContext, useEffect, useMemo, useState } from "react";
73
90
 
91
+ import { formatMinorUnits } from "../../../../../../lib/offerings-pricing";
74
92
  import { saveRecommendationAction } from "../../save.actions";
75
93
 
76
94
  import type {
@@ -82,8 +100,27 @@ import { ResultsEmailStep } from "./ResultsEmailStep";
82
100
 
83
101
  export type ResultsReturnState = "success" | "cancelled";
84
102
 
103
+ /**
104
+ * #10827 — the matched by-result row's offering, resolved by the page from
105
+ * the shown set: named from the offering; `price` and `href` (its
106
+ * `/pricing?plan=` card) only while it is shown — a draft has neither.
107
+ */
108
+ export interface ResultsOfferingCard {
109
+ offeringKey: string;
110
+ title: string;
111
+ /** Stripe minor units, from the offering's own Price. */
112
+ price?: { amount: number; currency: string; period: LookupKeyPeriod };
113
+ href?: string;
114
+ /**
115
+ * A checkout row's shown offering: on load the browser goes to `href`, the
116
+ * Offerings buy route, as a top-level navigation; the card is the fallback.
117
+ */
118
+ checkoutOnLoad?: true;
119
+ }
120
+
85
121
  interface Props {
86
- config: FlowConfig;
122
+ /** The served config; `conversion` is the magnet's (#10826), absent from an older API. */
123
+ config: FlowConfig & { conversion?: FlowCompletion };
87
124
  locale: string;
88
125
  answers: Record<string, string | string[]>;
89
126
  slug: string;
@@ -91,6 +128,8 @@ interface Props {
91
128
  payload: string;
92
129
  /** FR7/D6 — the `?checkout=` return micro-state, validated by the page. */
93
130
  returnState?: ResultsReturnState;
131
+ /** #10827 — the matched by-result row's offering card. */
132
+ offeringCard?: ResultsOfferingCard;
94
133
  }
95
134
 
96
135
  type View = "results" | "checkout" | "save";
@@ -147,22 +186,34 @@ export function ResultsClient({
147
186
  slug,
148
187
  payload,
149
188
  returnState,
189
+ offeringCard,
150
190
  }: Props): ReactElement {
151
191
  const t = useTranslations("flow");
192
+ const tOfferings = useTranslations("pricingOfferings");
193
+ // #10828 — the score's two words, from the catalog's existing entries.
194
+ const tScore = useTranslations("account.results");
195
+ const tLevel = useTranslations("waitlistDashboard.level");
152
196
  const checkout = useContext(ResultsCheckoutContext);
153
197
  const { defaultLocale, offers = [], recommendation } = config;
154
198
 
155
- const register = useMemo<RecommendRegister>(
156
- () => ({
157
- key: config.experiment?.key ?? config.slug,
158
- offers: config.offers,
159
- pairings: config.pairings,
160
- rateTable: config.rateTable,
161
- scoring: config.scoring,
162
- }),
163
- [config],
164
- );
199
+ const register = useMemo<RecommendRegister>(() => flowRecommendRegister(config), [config]);
165
200
  const result = useMemo(() => recommend(register, answers), [register, answers]);
201
+ // #10828 — no points to score (max 0) is an unscored register. The
202
+ // evaluator returns `dimensions` 1:1 with, and in the order of, the
203
+ // register's own, so each takes its name by index.
204
+ const score = useMemo(() => {
205
+ const scoring = config.scoring;
206
+ if (!scoring) return undefined;
207
+ const scored = evaluateWaitlistScoring(scoring, answers);
208
+ if (scored.total.max <= 0) return undefined;
209
+ return {
210
+ total: scored.total,
211
+ dimensions: scored.dimensions.map((dimension, i) => ({
212
+ ...dimension,
213
+ name: scoring.dimensions?.[i]?.name ?? dimension.key,
214
+ })),
215
+ };
216
+ }, [config.scoring, answers]);
166
217
  const currency = config.rateTable?.currency;
167
218
 
168
219
  const [view, setView] = useState<View>("results");
@@ -200,6 +251,34 @@ export function ResultsClient({
200
251
  "one-time": t("priceCard.periodLabels.one-time"),
201
252
  };
202
253
 
254
+ /** #10827 — an offering's Price as `/pricing` words it. */
255
+ function offeringPriceLabel(price: NonNullable<ResultsOfferingCard["price"]>): string {
256
+ const amount = formatMinorUnits(price.amount, price.currency, locale);
257
+ if (price.period === "monthly") return tOfferings("monthly", { amount });
258
+ if (price.period === "yearly") return tOfferings("annual", { amount });
259
+ return tOfferings("oneTime", { amount });
260
+ }
261
+
262
+ const offeringHref = offeringCard?.href;
263
+ const checkoutOnLoad = offeringCard?.checkoutOnLoad === true;
264
+
265
+ // #10827 — straight to checkout: the buy route sells only on a top-level
266
+ // document load, which a server redirect inside the walk's client-side
267
+ // navigation is not. Only when this tab just walked the flow (the session
268
+ // entry `FlowStepperClient` writes before it navigates here) — a cold load
269
+ // of a shared or cross-site permalink, and a `?checkout=` return, show the
270
+ // card and wait for the click. `replace`, so Back from Stripe skips this page.
271
+ useEffect(() => {
272
+ if (!checkoutOnLoad || offeringHref === undefined || returnState !== undefined) return;
273
+ let walked = false;
274
+ try {
275
+ walked = Boolean(window.sessionStorage.getItem(flowSessionStorageKey(slug)));
276
+ } catch {
277
+ // a privacy mode: the click alone
278
+ }
279
+ if (walked) window.location.replace(offeringHref);
280
+ }, [checkoutOnLoad, offeringHref, returnState, slug]);
281
+
203
282
  const topFit = result.fits[0];
204
283
  const topOffer = topFit
205
284
  ? offers.find((offer) => offer.key === topFit.offerKey)
@@ -369,6 +448,8 @@ export function ResultsClient({
369
448
  if (view === "results") {
370
449
  const heading = recommendation ? resolve(recommendation.copy.title) : undefined;
371
450
  const body = recommendation?.copy.body ? resolve(recommendation.copy.body) : undefined;
451
+ const levelName = (level: number): string =>
452
+ config.scoring?.levels?.names[level - 1] ?? tLevel("label", { n: level });
372
453
 
373
454
  active = (
374
455
  <div data-testid="flow-results">
@@ -389,10 +470,71 @@ export function ResultsClient({
389
470
  {body}
390
471
  </Text>
391
472
  ) : null}
473
+ {score ? (
474
+ <div data-testid="flow-results-score" className="mt-block-loose flex flex-col gap-6">
475
+ <ScoreBar
476
+ size="lg"
477
+ label={tScore("score")}
478
+ points={score.total.points}
479
+ max={score.total.max}
480
+ pct={score.total.pct}
481
+ levelName={levelName(score.total.level)}
482
+ locale={locale}
483
+ data-testid="flow-results-score-total"
484
+ />
485
+ {score.dimensions.length > 0 ? (
486
+ <div className="flex flex-col gap-4">
487
+ {score.dimensions.map((dimension) => (
488
+ <ScoreBar
489
+ key={dimension.key}
490
+ label={dimension.name}
491
+ points={dimension.points}
492
+ max={dimension.max}
493
+ pct={dimension.pct}
494
+ levelName={levelName(dimension.level)}
495
+ locale={locale}
496
+ data-testid={`flow-results-score-dimension-${dimension.key}`}
497
+ />
498
+ ))}
499
+ </div>
500
+ ) : null}
501
+ </div>
502
+ ) : null}
392
503
  <div className="mt-block-loose flex flex-col gap-4">
504
+ {offeringCard ? (
505
+ <RecommendationCard
506
+ data-testid={`recommendation-card-${offeringCard.offeringKey}`}
507
+ title={offeringCard.title}
508
+ emphasis="recommended"
509
+ recommendedLabel={t("priceCard.eyebrow")}
510
+ {...(offeringCard.price
511
+ ? {
512
+ price: {
513
+ kind: "label",
514
+ label: { [locale]: offeringPriceLabel(offeringCard.price) },
515
+ currency: offeringCard.price.currency,
516
+ locale,
517
+ periodLabels,
518
+ fromPrefix: t("price.fromPrefix"),
519
+ },
520
+ }
521
+ : {})}
522
+ {...(offeringHref !== undefined
523
+ ? {
524
+ terminal: {
525
+ kind: "getStarted",
526
+ label: t("getStarted"),
527
+ onSelect: () => window.location.assign(offeringHref),
528
+ },
529
+ }
530
+ : {})}
531
+ />
532
+ ) : null}
393
533
  {result.fits.map((fit, index) => {
394
534
  const offer = offers.find((o) => o.key === fit.offerKey);
395
535
  if (!offer) return null;
536
+ // #10827 — one recommended card: a by-result card takes the badge.
537
+ const recommendedFit = index === 0 && !offeringCard;
396
538
  // Get Started only where commerce is on (#6786) AND the offer is quotable (D2).
397
539
  const quotable =
398
540
  checkout !== undefined &&
@@ -427,8 +569,8 @@ export function ResultsClient({
427
569
  {...(offer.copy.description
428
570
  ? { description: resolve(offer.copy.description) }
429
571
  : {})}
430
- emphasis={index === 0 ? "recommended" : "default"}
431
- {...(index === 0 ? { recommendedLabel: t("priceCard.eyebrow") } : {})}
572
+ emphasis={recommendedFit ? "recommended" : "default"}
573
+ {...(recommendedFit ? { recommendedLabel: t("priceCard.eyebrow") } : {})}
432
574
  {...(price !== undefined ? { price } : {})}
433
575
  terminal={terminal}
434
576
  whyThis={{ label: t("whyThis"), content: resolve(fit.reason) }}
@@ -448,11 +590,13 @@ export function ResultsClient({
448
590
  </div>
449
591
  </div>
450
592
  );
451
- leading = (
452
- <Button type="button" variant="ghost" size="big" onClick={openSave}>
453
- {t("emailMePlan")}
454
- </Button>
455
- );
593
+ // #10826 — a magnet that converts no one (`none`) asks for no email.
594
+ leading =
595
+ config.conversion === "none" ? undefined : (
596
+ <Button type="button" variant="ghost" size="big" onClick={openSave}>
597
+ {t("emailMePlan")}
598
+ </Button>
599
+ );
456
600
  trailing = undefined;
457
601
  } else {
458
602
  const isCheckout = view === "checkout";