create-ailk 0.37.1 → 0.39.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 (318) 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 +19 -12
  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 +12 -16
  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 +73 -2
  26. package/dist/routes.d.ts +130 -0
  27. package/dist/routes.js +954 -0
  28. package/dist/site-manifest.js +6 -4
  29. package/dist/site-roster.d.ts +11 -2
  30. package/dist/site-roster.js +63 -21
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +26 -0
  34. package/dist/surfaces.js +105 -293
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +108 -10
  37. package/dist/template-record.js +3 -1
  38. package/dist/topology.d.ts +26 -1
  39. package/dist/topology.js +273 -7
  40. package/dist/update.d.ts +17 -2
  41. package/dist/update.js +480 -77
  42. package/package.json +3 -3
  43. package/templates/README.md +1 -1
  44. package/templates/apps/mcp/CLAUDE.md +5 -3
  45. package/templates/apps/web/CLAUDE.md +87 -23
  46. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
  47. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
  48. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  49. package/templates/apps/web/account.config.tsx +100 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
  52. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/layout.tsx +46 -29
  54. package/templates/apps/web/app/apple-icon.tsx +72 -0
  55. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  56. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  57. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  58. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  59. package/templates/apps/web/app/og/route.tsx +155 -72
  60. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  61. package/templates/apps/web/auth.config.tsx +107 -0
  62. package/templates/apps/web/auth.ts +2 -1
  63. package/templates/apps/web/i18n/request.ts +51 -1
  64. package/templates/apps/web/jest.config.cjs +17 -1
  65. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  66. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
  67. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  68. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  69. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  70. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  71. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  72. package/templates/apps/web/lib/listings.tsx +2 -2
  73. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  74. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  75. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  76. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  77. package/templates/apps/web/lib/served-pages.ts +95 -0
  78. package/templates/apps/web/lib/server-api.ts +1 -1
  79. package/templates/apps/web/lib/site-brand.tsx +3 -5
  80. package/templates/apps/web/lib/topology.generated.ts +5 -0
  81. package/templates/apps/web/messages/en.json +8 -836
  82. package/templates/apps/web/middleware.ts +15 -26
  83. package/templates/apps/web/next.config.mjs +35 -0
  84. package/templates/apps/web/package.json +2 -0
  85. package/templates/apps/web/types/messages.d.ts +6 -1
  86. package/templates/customizations.yaml +9 -0
  87. package/templates/package.json +3 -1
  88. package/templates/tools/lint-architecture.ts +164 -11
  89. package/versions.json +49 -47
  90. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  91. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  92. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  93. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  94. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  95. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  96. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  97. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  98. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  99. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  100. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  101. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  102. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  103. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  104. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  105. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  106. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  107. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  108. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  109. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  110. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  111. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  112. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  113. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  114. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  115. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  116. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  117. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  118. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  119. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  120. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  121. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  122. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  123. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  124. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  125. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  126. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  127. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  128. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  129. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  130. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  131. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  132. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  133. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  134. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  135. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  136. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  137. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  138. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  139. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  140. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  141. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  142. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  143. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  144. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  145. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  146. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  147. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
  148. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  149. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  150. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
  151. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
  152. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  153. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  154. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
  155. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  156. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  157. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  158. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  159. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  160. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  161. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
  162. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  163. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  164. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
  165. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  166. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  167. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  168. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  169. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  170. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  171. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  172. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  173. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  174. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  175. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  176. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
  177. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  178. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  179. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  180. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  181. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  182. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
  183. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  184. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
  185. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  186. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
  187. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  188. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  189. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  190. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  191. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  192. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  193. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
  194. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
  195. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  196. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  197. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  198. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
  199. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  200. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  201. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
  202. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
  203. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  204. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  205. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
  206. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
  207. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  208. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  209. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  210. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
  211. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  212. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  213. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
  214. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  215. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  216. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
  217. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  218. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  219. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  220. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  221. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  222. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  223. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  224. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  225. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  226. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  227. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  228. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  229. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  230. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  231. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  232. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  233. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  234. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  235. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  236. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  237. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  238. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  239. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  240. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  241. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  242. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  243. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  244. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  245. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  246. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  247. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  248. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  249. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  250. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  251. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  252. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  253. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  254. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  255. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  256. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  257. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  258. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  259. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  260. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  261. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  262. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  263. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  264. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  265. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  266. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  267. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  268. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  269. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  270. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  271. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  272. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  273. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  274. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  275. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  276. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  277. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  278. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  279. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  280. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  281. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  282. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  283. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  284. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  285. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  286. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  287. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  288. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  289. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  290. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  291. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  292. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  293. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  294. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  295. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  296. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  297. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  298. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  299. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  300. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  301. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  302. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  303. package/templates/apps/web/lib/account-config.ts +0 -678
  304. package/templates/apps/web/lib/auth-routes.ts +0 -125
  305. package/templates/apps/web/lib/checkout-config.ts +0 -16
  306. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  307. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  308. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  309. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  310. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  311. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  312. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  313. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  314. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  315. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  316. package/templates/apps/web/lib/next-path.ts +0 -35
  317. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  318. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,820 +0,0 @@
1
- // oss: false
2
- "use client";
3
-
4
- /**
5
- * ResultsClient — the results permalink page's composition + view state
6
- * machine (#4842, redesigned by #11013 spec E): `results` → `checkout`.
7
- *
8
- * Runs the already-shipped pure `recommend()` on the decoded answers and
9
- * composes the takeover window the walk lives in (`FlowFrame`, decisions
10
- * 1–4 and 10–20 of docs/design-mocks/diagnostic-stepper-2026-11-06/README.md):
11
- *
12
- * - **results** — no bar (decision 4). The recommendation heading and body
13
- * where the register has them, then the **score** (decision 10): the
14
- * points as a display number at `--flow-score-size`, "of {max}", the
15
- * total's Level name and the `LevelChart` beside it; **Report Compiled**
16
- * (decision 12) over one `ScoreBar` per dimension in register order; at
17
- * most **one card** (decisions 14, 15 — straight to checkout, a by-result
18
- * row's offering, the magnet's Email-links-to offering or appointment,
19
- * else the older offer, the top fit as `RecommendationCard`); and the
20
- * **Get your full report** form (decisions 13, 17, 18), inline, only when
21
- * the walk asked no required email question and the conversion is not
22
- * `none`. With a card its button is the primary and Send it is an
23
- * outline button; with none Send it is primary (decision 16). From `md:`
24
- * a two-column grid (score, Report Compiled and the form on the left,
25
- * the card on the right); below it one column — score, Report Compiled,
26
- * card, form — with the primary in a sticky bottom wrapper.
27
- * - **checkout** — Get Started performs DESIGN §7.6's panel FLIP: the
28
- * email step takes the frame's first (side) slot and the configurable
29
- * price card (#4865, D3) the second (active) slot; the card is
30
- * controlled here, so its seat / period / credit-stop state is EXACTLY
31
- * what Pay sends. Bar `leading` = Back, `trailing` = Pay. Unchanged.
32
- *
33
- * The score is `evaluateWaitlistScoring` over the decoded answers, run here
34
- * as `recommend()` is (#10828); a Level is named by the register's
35
- * `levels.names` (five since #11034), else "Level {n}" for the total and
36
- * "L{n}" on a dimension bar. An unscored register (no scoring, or no points
37
- * to score) renders none of the score, the chart or Report Compiled
38
- * (decision 19).
39
- *
40
- * The frame's regions keep their DOM identity across every transition
41
- * (#4806 FR7 — the frame is rendered once; only its slots change).
42
- *
43
- * Checkout is commerce's optional add-on to this signal-collectors page
44
- * (#6786): the price card and Pay come from `ResultsCheckoutContext`
45
- * (`checkout-seam.ts`), which commerce's `layout.tsx` provides. The Meeting
46
- * card is scheduling's the same way (#11013 D-K): `ResultsMeetingContext`
47
- * (`meeting-seam.ts`), provided by scheduling's `../layout.tsx` with at most
48
- * the one meeting the magnet's `conversionLink` names. Without either, the
49
- * context stays `undefined` and the page offers neither.
50
- *
51
- * Before a terminal or Send it is selected AND a valid email submitted, this
52
- * component makes no request of any kind (FR5 / PRD L108): the only network
53
- * calls on the page are the server component's.
54
- *
55
- * `RecommendRegister` (D6, #4770) is a structural `Pick` of the five fields
56
- * `recommend()` / `price()` read — `key`, `offers`, `pairings`, `rateTable`,
57
- * `scoring` — so a `FlowConfig` needs only a `key` to satisfy it; the
58
- * compiled config carries the register's own key on `experiment.key`.
59
- */
60
- import type {
61
- FlowFrameBrand,
62
- RecommendationCardPrice,
63
- RecommendationCardTerminal,
64
- } from "@working-theory/ui";
65
- import {
66
- Button,
67
- FlowFrame,
68
- Heading,
69
- Link,
70
- RecommendationCard,
71
- ScoreBar,
72
- Text,
73
- } from "@working-theory/ui";
74
- import type {
75
- FlowCompletion,
76
- FlowConfig,
77
- FlowConversionLink,
78
- FlowSaveInput,
79
- LookupKeyPeriod,
80
- RecommendRegister,
81
- WaitlistBillingPeriod,
82
- } from "@working-theory/validation";
83
- import {
84
- evaluateWaitlistScoring,
85
- flowRecommendRegister,
86
- lookupKeyPeriodSchema,
87
- recommend,
88
- resolveLocalizedString,
89
- resultsPageAsksEmail,
90
- } from "@working-theory/validation";
91
- import { useTranslations } from "next-intl";
92
- import type { CSSProperties, ReactElement, ReactNode } from "react";
93
- import { useContext, useEffect, useMemo, useState } from "react";
94
-
95
- import { formatMinorUnits } from "../../../../../../lib/offerings-pricing";
96
- import { sendResultsEmailAction } from "../../save.actions";
97
-
98
- import type {
99
- ResultsCheckoutConfiguration,
100
- ResultsCheckoutInput,
101
- } from "./checkout-seam";
102
- import { ResultsCheckoutContext } from "./checkout-seam";
103
- import { LevelChart } from "./LevelChart";
104
- import { ResultsMeetingContext } from "./meeting-seam";
105
- import { ResultsCard } from "./ResultsCard";
106
- import { ResultsEmailStep } from "./ResultsEmailStep";
107
-
108
- export type ResultsReturnState = "success" | "cancelled";
109
-
110
- /**
111
- * #10827 — the matched by-result row's offering, resolved by the page from
112
- * the shown set: named from the offering; `price` and `href` (its
113
- * `/pricing?plan=` card) only while it is shown — a draft has neither.
114
- * #11013 D-G — its Stripe `description` and `features` too, so the card is
115
- * the same Product card an Email-links-to offering draws.
116
- */
117
- export interface ResultsOfferingCard {
118
- offeringKey: string;
119
- title: string;
120
- /** Stripe minor units, from the offering's own Price. */
121
- price?: { amount: number; currency: string; period: LookupKeyPeriod };
122
- href?: string;
123
- description?: string;
124
- features?: string[];
125
- /**
126
- * A checkout row's shown offering: on load the browser goes to `href`, the
127
- * Offerings buy route, as a top-level navigation; the card is the fallback.
128
- */
129
- checkoutOnLoad?: true;
130
- }
131
-
132
- /**
133
- * #11013 D-G (3) — the magnet's Email-links-to offering, resolved by the
134
- * page from the shown set: the Product card. (An appointment's Meeting card
135
- * arrives through the scheduling seam, not here.)
136
- */
137
- export interface ResultsConversionCard {
138
- kind: "product";
139
- name: string;
140
- price?: ResultsOfferingCard["price"];
141
- description?: string;
142
- features?: string[];
143
- /** Get Started's landing, `/pricing?plan=`. */
144
- href: string;
145
- }
146
-
147
- interface Props {
148
- /**
149
- * The served config; `conversion`, `conversionLink` and `writtenReport`
150
- * are the magnet's (#10826, #11013 D5), absent from an older API.
151
- */
152
- config: FlowConfig & {
153
- conversion?: FlowCompletion;
154
- conversionLink?: FlowConversionLink;
155
- writtenReport?: boolean;
156
- };
157
- locale: string;
158
- answers: Record<string, string | string[]>;
159
- slug: string;
160
- /** The encoded permalink payload — the return URLs are built from it. */
161
- payload: string;
162
- /** FR7/D6 — the `?checkout=` return micro-state, validated by the page. */
163
- returnState?: ResultsReturnState;
164
- /** #10827 — the matched by-result row's offering card. */
165
- offeringCard?: ResultsOfferingCard;
166
- /** #11013 D-G — the magnet's Email-links-to offering, when no by-result card won. */
167
- conversionCard?: ResultsConversionCard;
168
- /** #11013 D-A — the frame's brand header, built by the page. */
169
- brand?: FlowFrameBrand;
170
- /** #11013 D-A — where Esc leaves for; the flow's landing by default. */
171
- exitHref?: string;
172
- }
173
-
174
- type View = "results" | "checkout";
175
-
176
- const EMAIL_FORM_ID = "flow-results-email";
177
-
178
- // Mirrors `FlowStepperClient.tsx` (#4707) — every path this component builds
179
- // passes its locale through the same build-time-baked allowlist, never the
180
- // raw route segment.
181
- const DEFAULT_LOCALE = "en";
182
- const ENABLED_LOCALES = (
183
- process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE
184
- ).split(",");
185
-
186
- /** Validate a candidate locale against the configured set; unknown → default. */
187
- function resolveSafeLocale(candidate: string): string {
188
- return ENABLED_LOCALES.includes(candidate) ? candidate : DEFAULT_LOCALE;
189
- }
190
-
191
- // #11013 decision 21 / spec E D-E — the score's size, read from
192
- // `--flow-score-size` with the display role as its fallback, declared under
193
- // this page's own property name so a site's `:root` declaration wins.
194
- const FLOW_SCORE_SIZE_STYLE = {
195
- "--ailk-flow-score-size": "var(--flow-score-size, var(--text-display))",
196
- } as CSSProperties;
197
-
198
- /** The sticky wrapper's safe-area inset (the FlowFrame bar's idiom). */
199
- const SAFE_BOTTOM_STYLE = {
200
- "--ailk-flow-safe-bottom": "max(env(safe-area-inset-bottom, 0px), 1rem)",
201
- } as CSSProperties;
202
-
203
- /**
204
- * Next's redirect control-flow error (`redirect()` inside a Server Action),
205
- * recognised by its digest — `NEXT_REDIRECT;<push|replace>;<url>;<status>;`
206
- * (`next/dist/client/components/redirect-error.js`). Never a checkout failure.
207
- */
208
- function isNextRedirect(err: unknown): boolean {
209
- return (
210
- typeof err === "object" &&
211
- err !== null &&
212
- "digest" in err &&
213
- typeof (err as { digest: unknown }).digest === "string" &&
214
- (err as { digest: string }).digest.startsWith("NEXT_REDIRECT;")
215
- );
216
- }
217
-
218
- /** D4 — the one `sessionStorage` key `FlowStepperClient` writes. */
219
- function flowSessionStorageKey(slug: string): string {
220
- return `ailk:flow-session:${slug}`;
221
- }
222
-
223
- /** D2 — an offer is quotable iff the register names a currency AND a seat rate for it. */
224
- function firstSeatRatePeriod(
225
- register: RecommendRegister,
226
- offerKey: string,
227
- ): WaitlistBillingPeriod | undefined {
228
- const rateTable = register.rateTable;
229
- if (rateTable?.currency === undefined) return undefined;
230
- return rateTable.seatRates.find((rate) => rate.offer === offerKey)?.period;
231
- }
232
-
233
- /** The primary action, mirrored into the phone's dock (decision 16): a card's link, a fit's terminal, or Send it. */
234
- type PrimaryAction =
235
- | { label: string; href: string }
236
- | { label: string; onSelect: () => void }
237
- | { label: string; form: string };
238
-
239
- export function ResultsClient({
240
- config,
241
- locale,
242
- answers,
243
- slug,
244
- payload,
245
- returnState,
246
- offeringCard,
247
- conversionCard,
248
- brand,
249
- exitHref,
250
- }: Props): ReactElement {
251
- const t = useTranslations("flow");
252
- const tOfferings = useTranslations("pricingOfferings");
253
- const tLevel = useTranslations("waitlistDashboard.level");
254
- const checkout = useContext(ResultsCheckoutContext);
255
- // #11013 D-K — the one meeting the scheduling layout provides, if any.
256
- const meeting = useContext(ResultsMeetingContext);
257
- const { defaultLocale, offers = [], recommendation } = config;
258
-
259
- const register = useMemo<RecommendRegister>(() => flowRecommendRegister(config), [config]);
260
- // #11013 D-C — a recommending flow with neither `offers` nor by-result rows
261
- // reaches this page now; `recommend()` refuses such a register, so it is
262
- // asked nothing and the page has no fit to show.
263
- const result = useMemo(
264
- () =>
265
- register.offers !== undefined || register.byResult !== undefined
266
- ? recommend(register, answers)
267
- : undefined,
268
- [register, answers],
269
- );
270
- // #10828 — no points to score (max 0) is an unscored register. The
271
- // evaluator returns `dimensions` 1:1 with, and in the order of, the
272
- // register's own, so each takes its name by index.
273
- const score = useMemo(() => {
274
- const scoring = config.scoring;
275
- if (!scoring) return undefined;
276
- const scored = evaluateWaitlistScoring(scoring, answers);
277
- if (scored.total.max <= 0) return undefined;
278
- return {
279
- total: scored.total,
280
- dimensions: scored.dimensions.map((dimension, i) => ({
281
- ...dimension,
282
- name: scoring.dimensions?.[i]?.name ?? dimension.key,
283
- })),
284
- };
285
- }, [config.scoring, answers]);
286
- const currency = config.rateTable?.currency;
287
-
288
- const [view, setView] = useState<View>("results");
289
- const [selectedOfferKey, setSelectedOfferKey] = useState<string | undefined>();
290
- const [configuration, setConfiguration] = useState<ResultsCheckoutConfiguration>({
291
- seats: 1,
292
- period: "annual",
293
- creditStop: { kind: "none" },
294
- });
295
- const [sessionId, setSessionId] = useState<string | undefined>();
296
- const [pending, setPending] = useState(false);
297
- const [error, setError] = useState<string | undefined>();
298
- // #11013 D-F — the address the report was sent to; set, the form is "Sent to {email}."
299
- const [sentTo, setSentTo] = useState<string | undefined>();
300
-
301
- // D4 — read the walk's own session id; a privacy mode that throws, or no
302
- // entry at all, degrades to cold (the key is simply omitted from the body).
303
- useEffect(() => {
304
- try {
305
- const stored = window.sessionStorage.getItem(flowSessionStorageKey(slug));
306
- if (stored) setSessionId(stored);
307
- } catch {
308
- // cold load
309
- }
310
- }, [slug]);
311
-
312
- const resolve = (value: Parameters<typeof resolveLocalizedString>[0]): string =>
313
- resolveLocalizedString(value, locale, defaultLocale);
314
-
315
- const safeLocale = resolveSafeLocale(locale);
316
- const bookCallHref = `/${safeLocale}/meet`;
317
-
318
- const periodLabels: Record<WaitlistBillingPeriod, string> = {
319
- monthly: t("priceCard.periodLabels.monthly"),
320
- annual: t("priceCard.periodLabels.annual"),
321
- "one-time": t("priceCard.periodLabels.one-time"),
322
- };
323
-
324
- /** #10827 — an offering's Price as `/pricing` words it. */
325
- function offeringPriceLabel(price: NonNullable<ResultsOfferingCard["price"]>): string {
326
- const amount = formatMinorUnits(price.amount, price.currency, locale);
327
- if (price.period === lookupKeyPeriodSchema.enum.monthly) return tOfferings("monthly", { amount });
328
- if (price.period === lookupKeyPeriodSchema.enum.yearly) return tOfferings("annual", { amount });
329
- return tOfferings("oneTime", { amount });
330
- }
331
-
332
- const offeringHref = offeringCard?.href;
333
- const checkoutOnLoad = offeringCard?.checkoutOnLoad === true;
334
-
335
- // #10827 — straight to checkout: the buy route sells only on a top-level
336
- // document load, which a server redirect inside the walk's client-side
337
- // navigation is not. Only when this tab just walked the flow (the session
338
- // entry `FlowStepperClient` writes before it navigates here) — a cold load
339
- // of a shared or cross-site permalink, and a `?checkout=` return, show the
340
- // card and wait for the click. `replace`, so Back from Stripe skips this page.
341
- useEffect(() => {
342
- if (!checkoutOnLoad || offeringHref === undefined || returnState !== undefined) return;
343
- let walked = false;
344
- try {
345
- walked = Boolean(window.sessionStorage.getItem(flowSessionStorageKey(slug)));
346
- } catch {
347
- // a privacy mode: the click alone
348
- }
349
- if (walked) window.location.replace(offeringHref);
350
- }, [checkoutOnLoad, offeringHref, returnState, slug]);
351
-
352
- const topFit = result?.fits[0];
353
- const topOffer = topFit
354
- ? offers.find((offer) => offer.key === topFit.offerKey)
355
- : undefined;
356
- const selectedOffer = selectedOfferKey
357
- ? offers.find((offer) => offer.key === selectedOfferKey)
358
- : undefined;
359
-
360
- function startCheckout(offerKey: string): void {
361
- const period = firstSeatRatePeriod(register, offerKey);
362
- if (period === undefined) return; // D2 — never quotable → never reaches here
363
- setSelectedOfferKey(offerKey);
364
- setConfiguration({ seats: 1, period, creditStop: { kind: "none" } });
365
- setError(undefined);
366
- setView("checkout");
367
- }
368
-
369
- function back(): void {
370
- setError(undefined);
371
- setView("results");
372
- }
373
-
374
- function failureMessage(
375
- kind: string,
376
- retryAfterSeconds: number | undefined,
377
- fallbackKey: "checkoutError" | "submitError",
378
- ): string {
379
- if (kind === "rate_limited" && retryAfterSeconds !== undefined) {
380
- return t("rateLimited", { seconds: retryAfterSeconds });
381
- }
382
- return t(fallbackKey);
383
- }
384
-
385
- async function handlePay(email: string): Promise<void> {
386
- if (selectedOfferKey === undefined || checkout === undefined) return;
387
- setPending(true);
388
- setError(undefined);
389
- // The Stripe return URLs are built by the action from the app's own
390
- // origin + this permalink (security review, #4875) — never sent from here.
391
- const body: ResultsCheckoutInput = {
392
- answers,
393
- email,
394
- locale,
395
- offerKey: selectedOfferKey,
396
- seats: configuration.seats,
397
- period: configuration.period,
398
- creditStop: configuration.creditStop,
399
- payload,
400
- ...(sessionId !== undefined ? { sessionId } : {}),
401
- };
402
- try {
403
- const outcome = await checkout.start(slug, body);
404
- // On success the action `redirect()`s — a returned value is always a
405
- // failure.
406
- if (outcome) {
407
- setError(failureMessage(outcome.kind, outcome.retryAfterSeconds, "checkoutError"));
408
- setPending(false);
409
- }
410
- } catch (err) {
411
- // A NEXT_REDIRECT is the SUCCESS path — Stripe's hosted page. It is
412
- // Next's control-flow error, never a checkout failure: the router is
413
- // already navigating (the action response carried the redirect), so it
414
- // is left alone — `pending` stays set and no error renders. Rethrowing
415
- // from an event handler would reach no framework boundary; it would
416
- // only be an unhandled rejection. Only a genuine transport failure
417
- // lands in the error micro-state below.
418
- if (isNextRedirect(err)) return;
419
- setError(t("checkoutError"));
420
- setPending(false);
421
- }
422
- }
423
-
424
- // #11013 D-F — Send it: the results-email route runs the conversion.
425
- async function handleSendReport(email: string): Promise<void> {
426
- setPending(true);
427
- setError(undefined);
428
- const body: FlowSaveInput = {
429
- answers,
430
- email,
431
- locale: safeLocale,
432
- ...(sessionId !== undefined ? { sessionId } : {}),
433
- };
434
- try {
435
- const outcome = await sendResultsEmailAction(slug, body);
436
- if (outcome.ok) {
437
- setSentTo(email);
438
- } else {
439
- setError(failureMessage(outcome.kind, outcome.retryAfterSeconds, "submitError"));
440
- }
441
- } catch {
442
- setError(t("submitError"));
443
- } finally {
444
- setPending(false);
445
- }
446
- }
447
-
448
- // The frame's regions carry no inner padding of their own (FlowFrame.tsx
449
- // :151/:159) — the consumer pads, exactly as FlowStepper does for its step
450
- // body (`mx-auto w-full max-w-container-sm p-card`, FlowStepper.tsx:1280).
451
- const REGION_CLASS = "mx-auto w-full max-w-container-sm p-card";
452
-
453
- // DESIGN §7.6 — the configurable price card, rendered into the frame's
454
- // SECOND slot (right at md+) on the checkout view; the email step takes the
455
- // first slot. Composed once here, placed below.
456
- let priceCard: ReactNode;
457
- if (view === "checkout" && selectedOffer && currency !== undefined && checkout) {
458
- priceCard = (
459
- <div className={REGION_CLASS}>
460
- <checkout.PriceCard
461
- offer={selectedOffer}
462
- currency={currency}
463
- locale={locale}
464
- {...(defaultLocale !== undefined ? { defaultLocale } : {})}
465
- register={register}
466
- value={configuration}
467
- onChange={setConfiguration}
468
- />
469
- </div>
470
- );
471
- }
472
-
473
- // ── The one card (decision 15) ───────────────────────────────────────────
474
- //
475
- // (1) a checkout row — `offeringCard` with `checkoutOnLoad`; (2) a by-result
476
- // offering row — `offeringCard`; (3) Email links to — `conversionCard`
477
- // (offering) or the seam's `meeting` (appointment, only the one the link
478
- // names); (4) the older offer — the top fit. First present wins.
479
- const link = config.conversionLink;
480
- const meetingCard =
481
- link?.kind === "appointment" && meeting !== undefined && meeting.slug === link.id
482
- ? meeting
483
- : undefined;
484
-
485
- let card: ReactNode;
486
- let primary: PrimaryAction | undefined;
487
- if (offeringCard) {
488
- const action = offeringHref !== undefined ? { href: offeringHref, label: t("getStarted") } : undefined;
489
- card = (
490
- <ResultsCard
491
- eyebrow={t("priceCard.eyebrow")}
492
- title={offeringCard.title}
493
- {...(offeringCard.price ? { price: offeringPriceLabel(offeringCard.price) } : {})}
494
- {...(offeringCard.description !== undefined ? { description: offeringCard.description } : {})}
495
- {...(offeringCard.features !== undefined ? { features: offeringCard.features } : {})}
496
- featuresLabel={t("whatsIncluded")}
497
- {...(action !== undefined ? { action } : {})}
498
- />
499
- );
500
- primary = action;
501
- } else if (conversionCard) {
502
- primary = { href: conversionCard.href, label: t("getStarted") };
503
- card = (
504
- <ResultsCard
505
- eyebrow={t("priceCard.eyebrow")}
506
- title={conversionCard.name}
507
- {...(conversionCard.price ? { price: offeringPriceLabel(conversionCard.price) } : {})}
508
- {...(conversionCard.description !== undefined ? { description: conversionCard.description } : {})}
509
- {...(conversionCard.features !== undefined ? { features: conversionCard.features } : {})}
510
- featuresLabel={t("whatsIncluded")}
511
- action={primary}
512
- />
513
- );
514
- } else if (meetingCard) {
515
- primary = { href: meetingCard.href, label: meetingCard.bookLabel };
516
- card = (
517
- <ResultsCard
518
- eyebrow={t("priceCard.eyebrow")}
519
- title={meetingCard.title}
520
- {...(meetingCard.description !== undefined ? { description: meetingCard.description } : {})}
521
- action={primary}
522
- />
523
- );
524
- } else if (topFit && topOffer) {
525
- // Get Started only where commerce is on (#6786) AND the offer is quotable (D2).
526
- const quotable =
527
- checkout !== undefined && firstSeatRatePeriod(register, topOffer.key) !== undefined;
528
- const onSelect = quotable
529
- ? () => startCheckout(topOffer.key)
530
- : () => window.location.assign(bookCallHref);
531
- const terminal: RecommendationCardTerminal = quotable
532
- ? { kind: "getStarted", label: t("getStarted"), onSelect }
533
- : { kind: "bookCall", label: t("bookCall"), onSelect };
534
- const price: RecommendationCardPrice | undefined =
535
- currency !== undefined
536
- ? {
537
- ...topOffer.price,
538
- currency,
539
- locale,
540
- ...(defaultLocale !== undefined ? { defaultLocale } : {}),
541
- periodLabels,
542
- fromPrefix: t("price.fromPrefix"),
543
- }
544
- : undefined;
545
- primary = { label: terminal.label, onSelect };
546
- card = (
547
- <RecommendationCard
548
- data-testid={`recommendation-card-${topFit.offerKey}`}
549
- title={resolve(topOffer.copy.name)}
550
- {...(topOffer.copy.description ? { description: resolve(topOffer.copy.description) } : {})}
551
- emphasis="recommended"
552
- recommendedLabel={t("priceCard.eyebrow")}
553
- {...(price !== undefined ? { price } : {})}
554
- terminal={terminal}
555
- whyThis={{ label: t("whyThis"), content: resolve(topFit.reason) }}
556
- />
557
- );
558
- }
559
- const hasCard = card !== undefined;
560
-
561
- // ── Get your full report (decisions 13, 17, 18) ──────────────────────────
562
- const asksEmail =
563
- resultsPageAsksEmail(config) && config.conversion !== undefined && config.conversion !== "none";
564
- const formHeading =
565
- (config.resultsPage?.formHeading !== undefined
566
- ? resolve(config.resultsPage.formHeading)
567
- : undefined) ??
568
- (config.writtenReport === true ? t("resultsFormHeadingReport") : t("resultsFormHeadingResults"));
569
- const formButton =
570
- (config.resultsPage?.formButton !== undefined ? resolve(config.resultsPage.formButton) : undefined) ??
571
- t("resultsFormButton");
572
- // Decision 16 — with no card, Send it is the primary: on a phone a docked
573
- // copy submits the form while the form itself stays in flow.
574
- if (primary === undefined && asksEmail && sentTo === undefined) {
575
- primary = { label: formButton, form: EMAIL_FORM_ID };
576
- }
577
-
578
- // The total's Level name (spec A's pattern), and a dimension's short one.
579
- const names = config.scoring?.levels?.names;
580
- const totalLevelName = (level: number): string => names?.[level - 1] ?? tLevel("label", { n: level });
581
- const dimensionLevelName = (level: number): string => names?.[level - 1] ?? t("levelShort", { n: level });
582
-
583
- // ── Slots ────────────────────────────────────────────────────────────────
584
- //
585
- // `sidePanel` is the frame's FIRST slot; `active` is its SECOND. On the
586
- // results view the active region alone holds the page; on the checkout view
587
- // the slots FLIP (DESIGN §7.6 / §2's Checkout row): the email step is first
588
- // and the price card second.
589
-
590
- let sidePanel: ReactNode;
591
- let active: ReactNode;
592
- let leading: ReactNode;
593
- let trailing: ReactNode;
594
-
595
- if (view === "results") {
596
- const heading = recommendation ? resolve(recommendation.copy.title) : undefined;
597
- const body = recommendation?.copy.body ? resolve(recommendation.copy.body) : undefined;
598
- const column = "md:col-span-3";
599
-
600
- active = (
601
- <div
602
- data-testid="flow-results"
603
- className={hasCard ? "md:grid md:grid-cols-5 md:gap-x-10" : "mx-auto w-full max-w-container-sm"}
604
- >
605
- <div className={column}>
606
- {returnState !== undefined ? (
607
- <div
608
- role="status"
609
- data-testid="flow-results-return-state"
610
- className="mb-block-loose"
611
- >
612
- <Text variant="body-sm" tone="muted">
613
- {t(returnState === "success" ? "checkoutSuccess" : "checkoutCancelled")}
614
- </Text>
615
- </div>
616
- ) : null}
617
- {heading ? <Heading level={1}>{heading}</Heading> : null}
618
- {body ? (
619
- <Text variant="body" tone="muted" className="mt-block-tight">
620
- {body}
621
- </Text>
622
- ) : null}
623
- {score ? (
624
- <div
625
- data-testid="flow-results-score"
626
- className="mt-block-loose flex flex-col gap-5 md:flex-row md:items-end md:gap-8"
627
- style={FLOW_SCORE_SIZE_STYLE}
628
- >
629
- <div
630
- data-testid="flow-results-score-total"
631
- className="flex flex-row items-baseline gap-3 md:flex-col md:items-start md:gap-2 md:pb-6"
632
- >
633
- <span className="flex items-baseline gap-1.5 whitespace-nowrap">
634
- <span
635
- data-testid="flow-results-score-total-points"
636
- className="font-display font-semibold leading-none tracking-tight tabular-nums text-fg text-(length:--ailk-flow-score-size)"
637
- >
638
- {score.total.points.toLocaleString(locale)}
639
- </span>
640
- <Text as="span" variant="body" tone="muted">
641
- {t("scoreOutOf", { max: score.total.max })}
642
- </Text>
643
- </span>
644
- <Text
645
- as="span"
646
- variant="body-sm"
647
- className="font-semibold"
648
- data-testid="flow-results-score-total-level"
649
- >
650
- {totalLevelName(score.total.level)}
651
- </Text>
652
- </div>
653
- <LevelChart
654
- className="min-w-0 flex-1"
655
- level={score.total.level}
656
- pct={score.total.pct}
657
- label={t("levelChartLabel", {
658
- level: score.total.level,
659
- pct: Math.round(score.total.pct),
660
- })}
661
- />
662
- </div>
663
- ) : null}
664
- </div>
665
- {score && score.dimensions.length > 0 ? (
666
- <div
667
- data-testid="flow-results-report-compiled"
668
- className={`${column} mt-block-loose border-t border-(--color-border) pt-6`}
669
- >
670
- <Heading level={2} className="text-heading-4">
671
- {t("reportCompiled")}
672
- </Heading>
673
- <div className="mt-4 flex flex-col gap-4">
674
- {score.dimensions.map((dimension) => (
675
- <ScoreBar
676
- key={dimension.key}
677
- label={dimension.name}
678
- points={dimension.points}
679
- max={dimension.max}
680
- pct={dimension.pct}
681
- levelName={dimensionLevelName(dimension.level)}
682
- locale={locale}
683
- data-testid={`flow-results-score-dimension-${dimension.key}`}
684
- />
685
- ))}
686
- </div>
687
- </div>
688
- ) : null}
689
- {hasCard ? (
690
- <div className="mt-block-loose md:col-span-2 md:col-start-4 md:row-span-3 md:row-start-1 md:mt-0 md:self-start">
691
- {card}
692
- </div>
693
- ) : null}
694
- {asksEmail ? (
695
- <div className={`${column} mt-block-loose border-t border-(--color-border) pt-6`}>
696
- <ResultsEmailStep
697
- title={formHeading}
698
- formId={EMAIL_FORM_ID}
699
- labels={{
700
- invalidEmail: t("validationInvalidEmail"),
701
- placeholder: t("emailPlaceholder"),
702
- savedTitle: t("resultsSent", { email: sentTo ?? "" }),
703
- }}
704
- consent={t("resultsConsent")}
705
- action={{
706
- label: formButton,
707
- variant: hasCard ? "outline" : "default",
708
- ...(hasCard ? {} : { dockedBelowMd: true }),
709
- }}
710
- onSubmit={handleSendReport}
711
- pending={pending}
712
- {...(error !== undefined ? { error } : {})}
713
- saved={sentTo !== undefined}
714
- data-testid="flow-results-report"
715
- />
716
- </div>
717
- ) : null}
718
- </div>
719
- );
720
- } else {
721
- const emailStep = (
722
- <ResultsEmailStep
723
- title={t("emailStepTitle")}
724
- formId={EMAIL_FORM_ID}
725
- labels={{
726
- invalidEmail: t("validationInvalidEmail"),
727
- placeholder: t("emailPlaceholder"),
728
- savedTitle: t("savedTitle"),
729
- savedBody: t("savedBody"),
730
- }}
731
- onSubmit={handlePay}
732
- pending={pending}
733
- {...(error !== undefined ? { error } : {})}
734
- />
735
- );
736
- sidePanel = <div className={REGION_CLASS}>{emailStep}</div>;
737
- active = priceCard;
738
- leading = (
739
- <Button type="button" variant="ghost" size="big" onClick={back} disabled={pending}>
740
- {t("back")}
741
- </Button>
742
- );
743
- trailing = (
744
- <Button
745
- type="submit"
746
- form={EMAIL_FORM_ID}
747
- size="big"
748
- disabled={pending}
749
- data-testid="flow-results-pay"
750
- >
751
- {t("pay")}
752
- </Button>
753
- );
754
- }
755
-
756
- // Decision 16 — on a phone the card's button is anchored to the screen
757
- // bottom (the board's dock), a row below the page's own scroller so the
758
- // frame's middle region never overflows and its bottom fade never dims the
759
- // primary; from `md:` the card's own button suffices.
760
- const dock =
761
- primary !== undefined ? (
762
- <div
763
- data-testid="flow-results-dock"
764
- className="shrink-0 border-t border-(--color-border) bg-(--color-bg) px-5 pt-3 pb-(--ailk-flow-safe-bottom) md:hidden"
765
- style={SAFE_BOTTOM_STYLE}
766
- >
767
- {"href" in primary ? (
768
- <Button asChild size="big" className="min-h-11 w-full">
769
- <Link href={primary.href} variant="bare">
770
- {primary.label}
771
- </Link>
772
- </Button>
773
- ) : "form" in primary ? (
774
- <Button
775
- type="submit"
776
- form={primary.form}
777
- size="big"
778
- disabled={pending}
779
- className="min-h-11 w-full"
780
- data-testid="flow-results-dock-send"
781
- >
782
- {primary.label}
783
- </Button>
784
- ) : (
785
- <Button type="button" size="big" className="min-h-11 w-full" onClick={primary.onSelect}>
786
- {primary.label}
787
- </Button>
788
- )}
789
- </div>
790
- ) : null;
791
-
792
- return (
793
- <FlowFrame
794
- takeover
795
- barMode={view === "checkout" ? "explicit" : "none"}
796
- value={1}
797
- max={1}
798
- {...(brand !== undefined ? { brand } : {})}
799
- exit={{ href: exitHref ?? `/${safeLocale}/flows/${slug}`, label: t("exitLabel") }}
800
- sidePanel={sidePanel}
801
- leading={leading}
802
- trailing={trailing}
803
- data-testid="flow-results-frame"
804
- >
805
- {view === "checkout" ? (
806
- active
807
- ) : (
808
- <div className="flex min-h-0 w-full flex-1 flex-col">
809
- <div
810
- data-testid="flow-results-scroller"
811
- className="min-h-0 flex-1 overflow-y-auto md:min-h-fit md:flex-none md:overflow-visible"
812
- >
813
- <div className="mx-auto w-full max-w-container-lg p-card">{active}</div>
814
- </div>
815
- {dock}
816
- </div>
817
- )}
818
- </FlowFrame>
819
- );
820
- }