create-ailk 0.37.1 → 0.38.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 (230) hide show
  1. package/README.md +129 -0
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +2 -2
  6. package/dist/add-route.js +18 -11
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +86 -5
  37. package/dist/topology.d.ts +15 -1
  38. package/dist/topology.js +20 -4
  39. package/dist/update.d.ts +17 -2
  40. package/dist/update.js +480 -77
  41. package/package.json +3 -3
  42. package/templates/README.md +1 -1
  43. package/templates/apps/mcp/CLAUDE.md +5 -3
  44. package/templates/apps/web/CLAUDE.md +62 -20
  45. package/templates/apps/web/account.config.tsx +101 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  47. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  52. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  54. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  55. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  57. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  58. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  59. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  60. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  61. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  62. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  63. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  64. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  65. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  66. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  67. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  68. package/templates/apps/web/app/apple-icon.tsx +72 -0
  69. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  70. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  71. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  72. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  73. package/templates/apps/web/app/og/route.tsx +155 -72
  74. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  75. package/templates/apps/web/i18n/request.ts +44 -1
  76. package/templates/apps/web/jest.config.cjs +13 -1
  77. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  78. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  79. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  80. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  81. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  82. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  83. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  84. package/templates/apps/web/lib/listings.tsx +2 -2
  85. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  86. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  87. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  88. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  89. package/templates/apps/web/lib/served-pages.ts +95 -0
  90. package/templates/apps/web/lib/site-brand.tsx +3 -5
  91. package/templates/apps/web/messages/en.json +8 -684
  92. package/templates/apps/web/middleware.ts +3 -1
  93. package/templates/apps/web/next.config.mjs +27 -0
  94. package/templates/apps/web/package.json +1 -0
  95. package/templates/customizations.yaml +9 -0
  96. package/templates/package.json +3 -1
  97. package/templates/tools/lint-architecture.ts +164 -11
  98. package/versions.json +48 -47
  99. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  100. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  119. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  120. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  121. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  122. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  123. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  125. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  126. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  127. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  128. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  135. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  136. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  138. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  139. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  140. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  141. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  142. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  153. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  154. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  157. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  158. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  161. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  162. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  164. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  165. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  166. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  167. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  168. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  169. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  170. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  171. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  173. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  174. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  175. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  176. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  177. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  178. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  179. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  180. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  181. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  182. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  183. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  195. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  196. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  197. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  198. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  199. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  200. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  201. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  214. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  215. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  216. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  217. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  218. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  219. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  220. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  221. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  222. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  224. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  225. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  226. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  227. package/templates/apps/web/lib/account-config.ts +0 -678
  228. package/templates/apps/web/lib/checkout-config.ts +0 -16
  229. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  230. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,614 +0,0 @@
1
- // oss: false
2
- "use client";
3
-
4
- /**
5
- * FlowStepperClient — the thin client wrapper that owns the web-layer
6
- * wiring for FlowStepper (#3957 D8): builds `messages` from the `flow`
7
- * next-intl namespace and binds `onSubmitStep` directly to the
8
- * `submitFlowStepAction` Server Action (React 19 supports calling Server
9
- * Actions directly — no `useFormState`; the stepper needs the response
10
- * payload on every per-step call).
11
- *
12
- * Segment-keyed completion redirect (#3960 D5): when the served config
13
- * carries a `thankYou` block, the client supplies `onCompleted` — resolve
14
- * the slug (D4's pure `resolveThankYouSlug`), then navigate to the
15
- * locale-prefixed `/thanks/<slug>` route. The redirect's ONLY inputs are the
16
- * active route `locale` and the config-declared, kebab-case slug the
17
- * resolver returns — no submitted form value (email/name/phone/free text)
18
- * ever reaches the URL (AC2). With no `thankYou` block, `onCompleted` is
19
- * never passed — `FlowStepper`'s own in-component completion state renders,
20
- * byte-identical to #3957 (AC4).
21
- *
22
- * Permalink completion redirect (#4770 D1/D7/D12): on a `mode:"recommending"`
23
- * flow, completion instead navigates to that flow's results permalink —
24
- * `/flows/<slug>/results/<payload>`, where `<payload>` encodes the answers
25
- * the visitor SUBMITTED (never an unsubmitted, part-filled edit) to the
26
- * flow's `segmentation`-typed questions ONLY (never a `field`-step value,
27
- * mapped or unmapped — the PRD's "answers, never identity" constraint, D7).
28
- * `FlowStepper.tsx` itself is not touched: this client accumulates its own
29
- * copy of the answered state — `answersRef` below — from the RESOLVED
30
- * result of the `onSubmitStep` calls it already forwards (D1), because
31
- * `FlowStepper`'s own `onCompleted` payload carries no answers today
32
- * (`{ segment?, aeoScore? }` only). `onCompleted` is passed whenever the
33
- * config carries a `thankYou` block OR is a recommending flow (D12) — a
34
- * recommending flow's terminal is the compiled `recommendation` marker, not
35
- * a `thankYou` block, so without this widening the callback would never be
36
- * supplied on a recommending flow at all.
37
- *
38
- * Per-tier completion redirect (#10616 D4): when a `scoring.tiers[]` entry
39
- * carries a `thankYou` slug, the client scores the walk's own answers
40
- * (`resolveTierThankYouSlug`) and navigates to the scored tier's
41
- * `/thanks/<slug>` AHEAD of the results permalink and the `thankYou` block;
42
- * a tier with no slug, or a flow with none, continues exactly as before. The
43
- * answers are read to score, never written into the href.
44
- *
45
- * Sign-up landing (#10826 D6, after #8771 D5): when the walk completes on a
46
- * `user` magnet (the step response's `next` is `{ completion: "invite" }`),
47
- * the client asks `accountInviteLinkAction` for the sign-in link with the
48
- * email the visitor gave already filled in, and navigates there at once —
49
- * a full navigation (`window.location.assign`), because a hub sign-in path is
50
- * not a Next route. A `null` link (no sign-in on this site) ends the walk as
51
- * before. A response carrying a `deliverable` never navigates (#8848 D8): the
52
- * sign-up landing then reaches the respondent through the verification
53
- * email's confirm (D5). The email never enters a URL the walk navigates to
54
- * other than that sign-in link itself.
55
- *
56
- * The standard magnet's parts (#8840 D9): the consent registry is the
57
- * platform default with the locale's `/terms` and `/privacy` links
58
- * (`consentPoliciesFor`, the map every agreement surface uses); a `message`
59
- * step is shown but not counted in "Step N of M"; `hiddenValues` and `header`
60
- * pass through from the page, as do the frame's `brand`, `exit` and
61
- * `presentation` (#11013 D-A — the page builds the brand on the server and
62
- * hands it down; the walk's Esc leaves for where it was entered from).
63
- *
64
- * The results page's reach (#11013 D-J): a recommending flow with no
65
- * `ending` has a results page (`hasResultsPage`, spec C), whether or not it
66
- * carries `offers`. `isRecommending` keeps its `offers` condition — its three
67
- * readers are kept as they were, so a recommending `user` magnet still lands
68
- * on sign-up at once (`goToSignUp`) — and a separate predicate,
69
- * `showsResultsPage`, drives only the results push: a walk changes landing
70
- * only when it is recommending with no ending, no `offers`, no sign-up
71
- * hand-off and no deliverable (`deliveredRef`), and then pushes the results
72
- * permalink instead of ending in the stepper's completed state. Every other
73
- * walk lands where it landed before. When the config carries an `ending`, it is the
74
- * one ending: `onCompleted` is not passed (so neither `thankYou` nor a
75
- * recommending flow's permalink runs), and on the completing response the
76
- * client picks the outcome from the answers it accumulated
77
- * (`selectFlowEndingOutcome`) — a screen in the stepper's finished card,
78
- * `{name}` filled from the walk, or a redirect to a site path. Every
79
- * destination is re-checked against `flowSitePathSchema` before it renders or
80
- * navigates (the served config is not re-parsed, SEC-8840-H).
81
- *
82
- * The deliverable (#8848 D8): a completing response's `deliverable` is drawn
83
- * after the ending screen — the reader link for a file (its grant in `?g=`,
84
- * inside a `data-sentry-block` element), an inline player for a video, a link
85
- * for a page or an outside address — each target re-checked before it
86
- * renders. A redirect ending never runs when the response carries one, and a
87
- * gated file walk whose response has none says the link is in the email.
88
- *
89
- * Locale validation before interpolation (AILK #4707, security review on
90
- * samhenry PR #163): the `[locale]` route segment is a Next.js dynamic
91
- * segment — the framework matches ANY string there, and next-intl's
92
- * middleware only rewrites/redirects for locale *detection*, it does not
93
- * reject an already-present, non-configured locale prefix from reaching
94
- * this component. Interpolating that unvalidated value into the redirect
95
- * path would let an unexpected/malformed segment ride into the pushed URL.
96
- * `resolveSafeLocale` validates it against the same build-time-baked
97
- * `NEXT_PUBLIC_ENABLED_LOCALES` list `middleware.ts` reads (mirrored here,
98
- * not imported from `@working-theory/web-i18n`'s `readLocales()` — that
99
- * helper falls back to a `node:fs` read that has no place in a client
100
- * bundle, the same reasoning `middleware.ts` already documents for the
101
- * Edge runtime) before it ever reaches the template literal.
102
- */
103
- import type { FlowFrameBrand, FlowFrameExit, FlowFramePresentation } from "@working-theory/ui";
104
- import { Button, Heading, Link, localeHref, Text } from "@working-theory/ui";
105
- import { VideoEmbed } from "@working-theory/ui/blocks";
106
- import {
107
- FlowStepper,
108
- type FlowStepperMessages,
109
- type FlowStepSubmitPayload,
110
- type FlowStepSubmitResult,
111
- } from "@working-theory/ui-signal-collectors";
112
- import type {
113
- AeoScoreResult,
114
- FlowConfig,
115
- FlowEndingOutcome,
116
- FlowState,
117
- FlowStepDeliverable,
118
- WaitlistAnswers,
119
- } from "@working-theory/validation";
120
- import {
121
- deriveFlags,
122
- encodePermalink,
123
- fillEndingName,
124
- flattenState,
125
- flowHttpsUrlSchema,
126
- flowSitePathSchema,
127
- flowStepDeliverableSchema,
128
- flowStepNextSchema,
129
- hasResultsPage,
130
- hiddenAnswers,
131
- PERMALINK_VERSION,
132
- pruneHiddenState,
133
- resolveLocalizedString,
134
- resolveThankYouSlug,
135
- resolveTierThankYouSlug,
136
- resultsPermalinkAnswers,
137
- selectFlowEndingOutcome,
138
- SITE_CONSENT_CONFIG_DEFAULTS,
139
- visitorNameOf,
140
- } from "@working-theory/validation";
141
- import { useRouter } from "next/navigation";
142
- import { useMessages, useTranslations } from "next-intl";
143
- import type { ReactElement, ReactNode } from "react";
144
- import { useRef, useState } from "react";
145
-
146
- import { consentPoliciesFor } from "../../../../lib/consent-policies";
147
-
148
- import { accountInviteLinkAction } from "./account-invite.actions";
149
- import { submitFlowStepAction } from "./flow.actions";
150
-
151
- interface Props {
152
- config: FlowConfig;
153
- locale: string;
154
- slug: string;
155
- /** #8840 D9 — page-supplied `hidden` field values (a posting's slug). */
156
- hiddenValues?: Readonly<Record<string, string>>;
157
- /** #8840 D9 — the walk's back arrow, above the step. Not rendered beside `brand` / `exit`. */
158
- header?: ReactNode;
159
- /** #11013 D-A — the frame's brand header (logomark, wordmark, the landing title). */
160
- brand?: FlowFrameBrand;
161
- /** #11013 D-A — the one `Esc ×` exit, to where the walk was entered from. */
162
- exit?: FlowFrameExit;
163
- /** #11013 decision 2 — a bounded window at `md:`+ (the default) or edge to edge. */
164
- presentation?: FlowFramePresentation;
165
- }
166
-
167
- const DEFAULT_LOCALE = "en";
168
- const ENABLED_LOCALES = (
169
- process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE
170
- ).split(",");
171
-
172
- /** Validate a candidate locale against the configured set; unknown → default. */
173
- function resolveSafeLocale(candidate: string): string {
174
- return ENABLED_LOCALES.includes(candidate) ? candidate : DEFAULT_LOCALE;
175
- }
176
-
177
- /**
178
- * #8771 D5 — the email the engine will land as the lead's: the first
179
- * `mapsTo: "email"` field of the submitted `field` step that holds a
180
- * non-empty string. Mirrors `extractMappedEmail` (a later step wins).
181
- */
182
- function mappedEmailOf(
183
- config: FlowConfig,
184
- payload: FlowStepSubmitPayload,
185
- ): string | undefined {
186
- const step = config.steps.find((s) => s.key === payload.stepKey);
187
- if (step?.type !== "field") return undefined;
188
- for (const field of step.fields) {
189
- if (field.mapsTo !== "email") continue;
190
- const value = payload.values[field.name];
191
- if (typeof value === "string" && value.trim() !== "") return value.trim();
192
- }
193
- return undefined;
194
- }
195
-
196
- /**
197
- * #8848 D8 — the completing response's `deliverable`, each target re-checked:
198
- * a video whose `src` is refused is nothing, a refused `poster` is dropped;
199
- * every other kind must parse whole.
200
- */
201
- function safeDeliverable(raw: unknown): FlowStepDeliverable | undefined {
202
- if (typeof raw !== "object" || raw === null) return undefined;
203
- const video = raw as { kind?: unknown; src?: unknown; poster?: unknown };
204
- if (video.kind === "video") {
205
- const src = flowHttpsUrlSchema.safeParse(video.src);
206
- if (!src.success) return undefined;
207
- const poster = flowHttpsUrlSchema.safeParse(video.poster);
208
- return { kind: "video", src: src.data, ...(poster.success ? { poster: poster.data } : {}) };
209
- }
210
- const parsed = flowStepDeliverableSchema.safeParse(raw);
211
- return parsed.success ? parsed.data : undefined;
212
- }
213
-
214
- /**
215
- * #8840 D9 — the answers the ending is chosen from, assembled as the
216
- * permalink path assembles them: the visible steps' answers flattened, then
217
- * the hidden segmentation steps' `whenHidden` answers. Narrowed to the
218
- * evaluator's string / string[] shape (#10616), which is all any reader keeps.
219
- */
220
- function walkAnswers(config: FlowConfig, state: FlowState): WaitlistAnswers {
221
- const flags = deriveFlags(config, state);
222
- const flat = flattenState(pruneHiddenState(config, state, flags));
223
- const answers: WaitlistAnswers = {};
224
- for (const [name, value] of Object.entries(
225
- Object.assign(flat, hiddenAnswers(config, state, flags)),
226
- )) {
227
- if (typeof value === "string" || Array.isArray(value)) {
228
- answers[name] = value as string | string[];
229
- }
230
- }
231
- return answers;
232
- }
233
-
234
- export function FlowStepperClient({
235
- config,
236
- locale,
237
- slug,
238
- hiddenValues,
239
- header,
240
- brand,
241
- exit,
242
- presentation,
243
- }: Props): ReactElement {
244
- const t = useTranslations("flow");
245
- const router = useRouter();
246
- const { thankYou } = config;
247
- // #4770 D8/D12 — the SAME predicate the results route's own server-side
248
- // guard uses (D8), so a flow the route would bounce is also a flow the
249
- // client never routes to.
250
- const isRecommending =
251
- config.mode === "recommending" && config.offers !== undefined;
252
- // #11013 D-J — spec C's predicate: the flow has a results page (recommending,
253
- // no ending), offers or not. It drives only the results push below;
254
- // `isRecommending`'s own readers are unchanged.
255
- const showsResultsPage = hasResultsPage(config);
256
- // #10616 D4 — a flow whose scoring maps at least one tier to a thank-you
257
- // page: completion may redirect there, so `onCompleted` is passed.
258
- const hasTierThankYou =
259
- config.scoring?.tiers.some((tier) => tier.thankYou !== undefined) === true;
260
-
261
- // #4770 D1 — the client's own accumulated answers, written from the
262
- // RESOLVED result of onSubmitStep (never the inbound payload) so a
263
- // rejected submission is never recorded and a `step_conflict` clears it,
264
- // mirroring exactly what FlowStepper does with its own `answers` state on
265
- // the same two paths.
266
- const answersRef = useRef<FlowState>({});
267
- // #4842 FR6/D4 — the last successful step response's own session id, so a
268
- // recommending completion can hand the walk's session to the results page
269
- // via `sessionStorage` (never the URL — the permalink stays answers-only).
270
- const lastSessionIdRef = useRef<string | undefined>(undefined);
271
- // #8771 D5 — the email the walk has landed. #10826 D6 — set once the walk
272
- // has left for the sign-up landing, so no other ending races it.
273
- const emailRef = useRef<string | undefined>(undefined);
274
- const signingUpRef = useRef(false);
275
- // #11013 D-J — set when the completing response (or the config) carried a
276
- // deliverable: the walk keeps it and never leaves for the results page.
277
- const deliveredRef = useRef(false);
278
- // #8840 D9 — a config with an `ending` ends on it, never on `thankYou` or
279
- // the permalink; the chosen screen is drawn in the finished card.
280
- const endingWins = config.ending !== undefined;
281
- const [endingContent, setEndingContent] = useState<ReactNode | undefined>(undefined);
282
- // #8848 D8 — the deliverable's action, drawn after the ending screen.
283
- const tReports = useTranslations("reports");
284
- const [deliverableContent, setDeliverableContent] = useState<ReactNode | undefined>(undefined);
285
-
286
- async function handleSubmitStep(
287
- payload: FlowStepSubmitPayload,
288
- ): Promise<FlowStepSubmitResult> {
289
- const result = await submitFlowStepAction(slug, payload);
290
- if (result.ok) {
291
- answersRef.current = {
292
- ...answersRef.current,
293
- [payload.stepKey]: payload.values,
294
- };
295
- lastSessionIdRef.current = result.response.sessionId;
296
- emailRef.current = mappedEmailOf(config, payload) ?? emailRef.current;
297
- if (result.response.completed) {
298
- const raw = (result.response as { deliverable?: unknown }).deliverable;
299
- // #8848 D8 — a deliverable (or a gated file's by-email line) is never
300
- // lost to a navigation.
301
- const hasDeliverable = raw !== undefined || config.deliverable !== undefined;
302
- deliveredRef.current = hasDeliverable;
303
- if (!hasDeliverable && (await goToSignUp(result.response))) return result;
304
- const delivered = showDeliverable(raw);
305
- if (endingWins) showEnding(delivered);
306
- }
307
- } else if (result.kind === "step_conflict") {
308
- answersRef.current = {};
309
- emailRef.current = undefined;
310
- }
311
- return result;
312
- }
313
-
314
- // #10826 D6 — on an `invite` completion (a `user` magnet) with a landed
315
- // email, ask the server for the prefilled sign-in link and go there. True
316
- // when the walk navigated; a rejected or null answer ends the walk as before.
317
- async function goToSignUp(response: unknown): Promise<boolean> {
318
- const next = flowStepNextSchema.safeParse(
319
- (response as { next?: unknown }).next,
320
- );
321
- const email = emailRef.current;
322
- if (!next.success || email === undefined || isRecommending) return false;
323
- let href: string | null;
324
- try {
325
- href = await accountInviteLinkAction(email);
326
- } catch {
327
- return false;
328
- }
329
- if (href === null) return false;
330
- signingUpRef.current = true;
331
- window.location.assign(href);
332
- return true;
333
- }
334
-
335
- // #8848 D8 — draw the response's deliverable (true when there is one), or,
336
- // for a gated file walk that minted no grant, the by-email line.
337
- function showDeliverable(raw: unknown): boolean {
338
- const deliverable = safeDeliverable(raw);
339
- if (deliverable !== undefined) {
340
- setDeliverableContent(deliverableAction(deliverable));
341
- return true;
342
- }
343
- const block = config.deliverable;
344
- setDeliverableContent(
345
- raw === undefined && block?.kind === "file" && block.gated ? (
346
- <Text className="mt-block-tight" data-testid="flow-deliverable-by-email">
347
- {tReports("fileByEmail")}
348
- </Text>
349
- ) : undefined,
350
- );
351
- return false;
352
- }
353
-
354
- function deliverableAction(deliverable: FlowStepDeliverable): ReactNode {
355
- const pick = (value: Record<string, string> | undefined): string | undefined =>
356
- value === undefined ? undefined : resolveLocalizedString(value, locale, config.defaultLocale);
357
- const label = pick(config.deliverable?.cta);
358
- if (deliverable.kind === "video") {
359
- return (
360
- <div className="mt-block-loose" data-testid="flow-deliverable-video">
361
- <VideoEmbed
362
- sources={[{ src: deliverable.src }]}
363
- {...(deliverable.poster !== undefined ? { poster: deliverable.poster } : {})}
364
- label={pick(config.deliverable?.title) ?? tReports("openFile")}
365
- />
366
- </div>
367
- );
368
- }
369
- const href =
370
- deliverable.kind === "file"
371
- ? localeHref(locale, `/reports/${slug}?g=${encodeURIComponent(deliverable.grantId)}`)
372
- : deliverable.kind === "page"
373
- ? localeHref(locale, deliverable.href)
374
- : deliverable.href;
375
- const fallback = deliverable.kind === "external" ? tReports("openExternal") : tReports("openFile");
376
- const link = (
377
- <Button asChild variant="default" className="min-h-11">
378
- <Link
379
- href={href}
380
- variant="bare"
381
- {...(deliverable.kind === "external" ? { external: true } : {})}
382
- data-testid="flow-deliverable-action"
383
- >
384
- {label ?? fallback}
385
- </Link>
386
- </Button>
387
- );
388
- // Session Replay records `href`s; the file's carries a bearer grant.
389
- return deliverable.kind === "file" ? (
390
- <div data-sentry-block className="mt-block-loose flex justify-center">
391
- {link}
392
- </div>
393
- ) : (
394
- <div className="mt-block-loose flex justify-center">{link}</div>
395
- );
396
- }
397
-
398
- // #8840 D9 — the ending for the walk's answers: a redirect to a site path,
399
- // else a screen; a destination the schema refuses is never rendered or
400
- // pushed (a refused redirect falls back to a screen `default`, else to the
401
- // stepper's own finished panel). #8848 D8 — with a deliverable in hand a
402
- // redirect never runs, so the deliverable is never lost to a navigation.
403
- function showEnding(delivered = false): void {
404
- const answers = walkAnswers(config, answersRef.current);
405
- const outcome = selectFlowEndingOutcome(config, resultsPermalinkAnswers(config, answers));
406
- if (outcome === undefined) return;
407
- if (outcome.kind === "redirect") {
408
- if (!delivered && flowSitePathSchema.safeParse(outcome.href).success) {
409
- setEndingContent(<></>);
410
- router.push(`/${resolveSafeLocale(locale)}${outcome.href}`);
411
- return;
412
- }
413
- const fallback = config.ending?.default;
414
- if (fallback?.kind === "screen") setEndingContent(endingScreen(fallback, answers));
415
- return;
416
- }
417
- setEndingContent(endingScreen(outcome, answers));
418
- }
419
-
420
- function endingScreen(
421
- outcome: Extract<FlowEndingOutcome, { kind: "screen" }>,
422
- answers: Record<string, unknown>,
423
- ): ReactNode {
424
- const name = visitorNameOf(config, answers);
425
- const text = (value: Record<string, string>) =>
426
- fillEndingName(resolveLocalizedString(value, locale, config.defaultLocale), name);
427
- const ctas = (outcome.ctas ?? []).filter(
428
- (cta) => flowSitePathSchema.safeParse(cta.href).success,
429
- );
430
- return (
431
- <div data-testid="flow-ending">
432
- <Heading level={2}>{text(outcome.headline)}</Heading>
433
- {outcome.body !== undefined ? (
434
- <Text className="mt-block-tight">{text(outcome.body)}</Text>
435
- ) : null}
436
- {ctas.length > 0 ? (
437
- <div className="mt-block-loose flex flex-wrap justify-center gap-4">
438
- {ctas.map((cta) => (
439
- <Button key={cta.href} asChild variant="default" className="min-h-11">
440
- <Link
441
- href={localeHref(locale, cta.href)}
442
- variant="bare"
443
- data-testid="flow-ending-cta"
444
- >
445
- {text(cta.label)}
446
- </Link>
447
- </Button>
448
- ))}
449
- </div>
450
- ) : null}
451
- </div>
452
- );
453
- }
454
-
455
- // #4663 D11 — `aeoScore` passes through untouched: this repo's segment
456
- // redirect is unchanged; C2's results page (on samhenry) is the consumer
457
- // of the score.
458
- function handleCompleted(result: {
459
- segment?: string;
460
- aeoScore?: AeoScoreResult;
461
- }): void {
462
- if (signingUpRef.current) return;
463
- // #10616 D4 — a scored tier's thank-you page wins over the permalink and
464
- // the `thankYou` block. Scored from the walk's answers as the server's
465
- // completion payload assembles them; no flags are passed (the server
466
- // scores with none).
467
- if (hasTierThankYou) {
468
- const tierSlug = resolveTierThankYouSlug(config, walkAnswers(config, answersRef.current));
469
- if (tierSlug !== undefined) {
470
- goToThanks(tierSlug);
471
- return;
472
- }
473
- }
474
-
475
- // #11013 D-J — the results push: a flow with `offers`, as before, or one
476
- // whose results page is reached with no deliverable in hand.
477
- if (isRecommending || (showsResultsPage && !deliveredRef.current)) {
478
- // D1 (hidden-step pruning) — apply the shipped visibility resolver to
479
- // the accumulated state before encoding, so an abandoned branch's
480
- // answers never reach the URL.
481
- const flags = deriveFlags(config, answersRef.current);
482
- const pruned = pruneHiddenState(config, answersRef.current, flags);
483
- const flat = flattenState(pruned);
484
-
485
- // Code-review finding (#4770): mirror the server's OWN completion-
486
- // payload assembly (flow-engine.ts's completeSubmission), which merges
487
- // `hiddenAnswers()` — the `whenHidden` auto-answers of every currently-
488
- // hidden segmentation step — in AFTER the visible-step values. Without
489
- // this, a config using `whenHidden` could silently score a different
490
- // recommendation on this cold-load permalink than the walk that
491
- // produced it. `hiddenAnswers` reads the UNPRUNED state (it derives its
492
- // own hidden/visible split internally) and only ever contributes
493
- // segmentation-question keys, so it composes safely with the D7 filter
494
- // below.
495
- Object.assign(flat, hiddenAnswers(config, answersRef.current, flags));
496
-
497
- // D7 — segmentation-only filter (`resultsPermalinkAnswers`, the
498
- // allowlist the Lead confirm's results landing shares, #10826 D5).
499
- const answers = resultsPermalinkAnswers(config, flat);
500
-
501
- const payload = encodePermalink({
502
- version: PERMALINK_VERSION,
503
- flowSlug: slug,
504
- answers,
505
- });
506
- // #4842 FR6/D4 — hand the walk's session id to the results page through
507
- // the per-tab `sessionStorage` (the key `ResultsClient` reads), never
508
- // through the permalink. Only on a recommending completion; a privacy
509
- // mode that throws degrades to a cold results page.
510
- const sessionId = lastSessionIdRef.current;
511
- if (typeof window !== "undefined" && sessionId) {
512
- try {
513
- window.sessionStorage.setItem(`ailk:flow-session:${slug}`, sessionId);
514
- } catch {
515
- // cold results page
516
- }
517
- }
518
- router.push(
519
- `/${resolveSafeLocale(locale)}/flows/${slug}/results/${payload}`,
520
- );
521
- return;
522
- }
523
-
524
- if (!thankYou) return;
525
- goToThanks(resolveThankYouSlug(thankYou, result.segment));
526
- }
527
-
528
- // The thank-you redirect's tail, shared by the `thankYou` block and a
529
- // scored tier's slug (#10616 D4).
530
- function goToThanks(thankYouSlug: string): void {
531
- router.push(`/${resolveSafeLocale(locale)}/thanks/${thankYouSlug}`);
532
- }
533
-
534
- // The typed-messages augmentation (types/messages.d.ts) restricts t.raw()
535
- // to leaf string keys, so the deliberately open-ended `flow.questions`
536
- // sub-object (D2/D4 — app-supplied, keyed by question `name`) is read via
537
- // useMessages() instead — untyped (AbstractIntlMessages), asserted to the
538
- // shape this namespace actually carries.
539
- const allMessages = useMessages() as unknown as {
540
- flow?: { questions?: Record<string, string> };
541
- };
542
- const questionPrompts = allMessages.flow?.questions ?? {};
543
-
544
- const messages: FlowStepperMessages = {
545
- progressLabel: (current, total) => t("progress", { current, total }),
546
- validation: {
547
- required: t("validationRequired"),
548
- invalidEmail: t("validationInvalidEmail"),
549
- selectOption: t("validationSelectOption"),
550
- tooLong: t("validationTooLong"),
551
- // #4663 D5/D4 — url/minLength/multi validation chrome.
552
- invalidUrl: t("validationInvalidUrl"),
553
- tooShort: t("validationTooShort"),
554
- selectAtLeastOne: t("validationSelectAtLeastOne"),
555
- },
556
- submitError: t("submitError"),
557
- // #4730 — distinct retryable message on a 429; receives the API's own
558
- // Retry-After-derived seconds.
559
- rateLimited: (seconds) => t("rateLimited", { seconds }),
560
- // #4708 — default submit-button label when a step's copy.cta is absent.
561
- next: t("next"),
562
- completedTitle: t("completedTitle"),
563
- completedBody: t("completedBody"),
564
- questionPrompts,
565
- // #4663 D8 — opt-in back-nav chrome string.
566
- goBack: t("goBack"),
567
- // #4663 D7 — shown while the invisible aeo_score step's submission is pending.
568
- computing: t("computing"),
569
- // #4802 D5 — the "Select all that apply" subline under a multi-select
570
- // question's prompt; a required FlowStepperMessages field as of #4802.
571
- selectAllThatApply: t("selectAllThatApply"),
572
- };
573
-
574
- // #8848 D8 — the ending screen, then the deliverable; with no ending the
575
- // stepper's own finished copy heads the action.
576
- const completedContent =
577
- deliverableContent !== undefined ? (
578
- <>
579
- {endingContent ?? (
580
- <>
581
- <Heading level={2}>{t("completedTitle")}</Heading>
582
- <Text className="mt-block-tight">{t("completedBody")}</Text>
583
- </>
584
- )}
585
- {deliverableContent}
586
- </>
587
- ) : (
588
- endingContent
589
- );
590
-
591
- return (
592
- <FlowStepper
593
- config={config}
594
- locale={locale}
595
- messages={messages}
596
- onSubmitStep={handleSubmitStep}
597
- {...(!endingWins &&
598
- (thankYou !== undefined || isRecommending || showsResultsPage || hasTierThankYou)
599
- ? { onCompleted: handleCompleted }
600
- : {})}
601
- // #8840 D9 — the locale's policy links, the input-step count, and the
602
- // page's hidden values, header and ending.
603
- consentConfig={{ ...SITE_CONSENT_CONFIG_DEFAULTS, policies: consentPoliciesFor(locale) }}
604
- uncountedStepKeys={config.steps.filter((step) => step.type === "message").map((step) => step.key)}
605
- {...(hiddenValues !== undefined ? { hiddenValues } : {})}
606
- {...(header !== undefined ? { header } : {})}
607
- // #11013 D-A — the frame's brand header, exit and presentation, unchanged.
608
- {...(brand !== undefined ? { brand } : {})}
609
- {...(exit !== undefined ? { exit } : {})}
610
- {...(presentation !== undefined ? { presentation } : {})}
611
- {...(completedContent !== undefined ? { completedContent } : {})}
612
- />
613
- );
614
- }
@@ -1,43 +0,0 @@
1
- // oss: false
2
- /**
3
- * #8840 D9, AC-3 — unmocked: with the real FlowStepper, a walk of three input
4
- * steps and a closing message reads "Step 1 of 3" — the closing message is
5
- * shown but not counted.
6
- */
7
- import { render, screen } from "@testing-library/react";
8
- import type { FlowConfig } from "@working-theory/validation";
9
-
10
- jest.mock("next/navigation", () => ({
11
- useRouter: () => ({ push: jest.fn() }),
12
- }));
13
-
14
- jest.mock("next-intl", () => ({
15
- useTranslations: () => (key: string, values?: Record<string, unknown>) =>
16
- key === "progress" ? `Step ${String(values?.["current"])} of ${String(values?.["total"])}` : key,
17
- useMessages: () => ({}),
18
- }));
19
-
20
- // eslint-disable-next-line no-restricted-syntax -- the boundary under test is the client wiring, not the actions
21
- jest.mock("../flow.actions", () => ({ submitFlowStepAction: jest.fn() }));
22
- // eslint-disable-next-line no-restricted-syntax -- see above
23
- jest.mock("../account-invite.actions", () => ({ accountInviteLinkAction: jest.fn() }));
24
-
25
- import { FlowStepperClient } from "../FlowStepperClient";
26
-
27
- const en = (s: string) => ({ en: s });
28
- const field = (key: string) => ({
29
- key,
30
- type: "field" as const,
31
- copy: { title: en(key) },
32
- fields: [{ name: key, inputType: "text" as const, copy: { label: en(key) } }],
33
- });
34
-
35
- it("counts the three input steps and not the closing message", () => {
36
- const config = {
37
- slug: "three",
38
- defaultLocale: "en",
39
- steps: [field("one"), field("two"), field("three"), { key: "bye", type: "message", copy: { title: en("Bye") } }],
40
- } as FlowConfig;
41
- render(<FlowStepperClient config={config} locale="en" slug="three" />);
42
- expect(screen.getByTestId("flow-stepper-progress-label").textContent).toBe("Step 1 of 3");
43
- });