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,303 +0,0 @@
1
- /**
2
- * account/billing-source.ts (server code) — what User settings › Billing
3
- * shows (#8232, spec docs/specs/8232-member-settings-account-general-and-spec.md
4
- * D9; #11165, the hub-read ruling of 2026-11-08).
5
- *
6
- * One of the account tree's TWO topology seams (roadmap D1; the other is
7
- * `sign-in-method.ts`): no other file under the account tree tests
8
- * `SIGN_IN_PROVIDER`, `TOPOLOGY` or `SIGN_IN_ENABLED`.
9
- *
10
- * `loadBilling()` — the plan card and the History rows:
11
- *
12
- * - On a spoke that signs in through its hub, the HUB reads them
13
- * (#11165): `member.billing(init)` with the hub credential answers the
14
- * caller's vouched customers and, since #11165, `billing` — the plan,
15
- * the History and whether a portal can open, read through the
16
- * workspace's Organization's own Stripe connection — so no spoke needs
17
- * a Stripe key or the commerce module for this page. `source: "hub"`
18
- * is served as read; its empty History falls back to the member's
19
- * purchase leads (`member.purchases`, #11096 D9), which carry no
20
- * receipt. `source: "none"` — the Organization has no usable
21
- * connection — and an older hub (no `billing`, or a 401, 403 or 404)
22
- * take the spec 8217 fallback: the spoke's OWN key through the
23
- * generated seam, `loadSpokeBilling()`, which reaches the rendered
24
- * `billing/spoke-billing.action.ts` on a spoke that carries commerce
25
- * and resolves `null` on one that does not — then `none` with no call.
26
- * `source: "failed"`, or any other non-2xx or a throw, is `failed` —
27
- * the error row, never a false "you have no subscription".
28
- * - Otherwise `subscription.me(init, { include: "billing" })` — the plan
29
- * name and the card summary are #8171's additive fields:
30
- * - 401, 403 or 404 (the commerce-disabled build answers 404), or a
31
- * 2xx whose `status` is `null` ⇒ `none` — the caller has no
32
- * subscription (C9);
33
- * - any other non-2xx, or a throw ⇒ `failed`, logged with the status
34
- * or `err.name`;
35
- * - otherwise `subscription`, absent optional fields read as `null`.
36
- * A single site reads no History here.
37
- *
38
- * `loadBillingOfferings()` (#11165) — the shown set's share of the page: the
39
- * base plan, the Upgrade target and the offer card (`billing/offerings.ts`),
40
- * read through `/pricing`'s own `readShownOfferings` (`lib/pricing-page.ts`:
41
- * shared per instance for 15 s, so a view costs no API call of its own); a
42
- * site that is not connected, an expired set or a failed read contributes
43
- * nothing.
44
- *
45
- * `billingPortalUrl()` is the one place a portal URL is minted, for
46
- * `openBillingPortal` (`actions.ts`): on a hub-mode spoke the hub's
47
- * `member.billingPortal(init)` (#11165) — a 404 means no portal there (an
48
- * older hub, no connection, no customer), so the spoke's own key through the
49
- * same loader is tried; otherwise the hub's portal route. `null` means no
50
- * portal — the action then redirects nowhere.
51
- */
52
-
53
- import { member, subscription } from "@working-theory/api-client";
54
- import {
55
- memberBillingPortalResponseSchema,
56
- memberBillingResponseSchema,
57
- type MemberBillingPlan,
58
- type MemberPurchase,
59
- } from "@working-theory/validation";
60
-
61
- import { readShownOfferings } from "../../../../lib/pricing-page";
62
- import { forwardedCookieInit } from "../../../../lib/server-api";
63
- import {
64
- SIGN_IN_PROVIDER,
65
- type SpokeBillingRead,
66
- loadSpokeBilling,
67
- } from "../../../../lib/topology.generated";
68
-
69
- import { logReadFailure } from "./account-data";
70
- import { billingOfferings, NO_BILLING_OFFERINGS, type BillingOfferings } from "./billing/offerings";
71
-
72
- /** The plan card's data — the hub's own shape, which the other two reads are mapped into. */
73
- export type BillingPlanState = MemberBillingPlan;
74
-
75
- export type BillingState =
76
- | {
77
- kind: "subscription";
78
- plan: BillingPlanState;
79
- portalAvailable: boolean;
80
- /** Some vouched billing is on a Stripe account this spoke's key cannot read (#8217 D12). */
81
- unreadable: boolean;
82
- }
83
- | { kind: "none"; unreadable: boolean }
84
- | { kind: "failed" };
85
-
86
- /** One History row: a hub-read invoice or purchase (with its receipt), or a purchase lead (without). */
87
- export type BillingHistoryItem = {
88
- id: string;
89
- paidAt: string;
90
- offering: string;
91
- amountMinor: number | null;
92
- currency: string | null;
93
- receiptUrl: string | null;
94
- };
95
-
96
- export type BillingHistoryState = { kind: "items"; items: BillingHistoryItem[] } | { kind: "failed" };
97
-
98
- export interface BillingRead {
99
- state: BillingState;
100
- history: BillingHistoryState;
101
- }
102
-
103
- /**
104
- * The statuses that mean "nothing to show this caller" — no subscription
105
- * (C9), no purchases (#11096 D9), no portal (#11165) — rather than a failed read.
106
- */
107
- const NOTHING_TO_SHOW_STATUSES: ReadonlySet<number> = new Set([401, 403, 404]);
108
-
109
- /** PII-safe error identity for logs (the `checkout.actions.ts` idiom: `err.name` only). */
110
- function errorName(err: unknown): string {
111
- return err instanceof Error ? err.name : "unknown";
112
- }
113
-
114
- const NO_HISTORY: BillingHistoryState = { kind: "items", items: [] };
115
- /** The whole read failed: one error row, so History claims nothing of its own. */
116
- const FAILED: BillingRead = { state: { kind: "failed" }, history: NO_HISTORY };
117
-
118
- function purchaseRow(purchase: MemberPurchase): BillingHistoryItem {
119
- return {
120
- id: purchase.id,
121
- paidAt: purchase.purchasedAt,
122
- offering: purchase.offering,
123
- amountMinor: purchase.amountMinor,
124
- currency: purchase.currency,
125
- receiptUrl: null,
126
- };
127
- }
128
-
129
- /** A hub-mode spoke's own-key Billing: the rendered action through the seam, else none (#8217 D10). */
130
- async function loadSpokeBillingState(): Promise<BillingState> {
131
- let read: SpokeBillingRead | null;
132
- try {
133
- const billing = await loadSpokeBilling();
134
- read = billing === null ? null : await billing.read();
135
- } catch (err) {
136
- logReadFailure("spoke-billing", err);
137
- return { kind: "failed" };
138
- }
139
- if (read === null) return { kind: "none", unreadable: false };
140
- if (read.kind !== "subscription") return read;
141
- return {
142
- kind: "subscription",
143
- plan: {
144
- name: read.planName,
145
- status: read.status,
146
- price: null,
147
- renewsAt: null,
148
- accessEndsAt: null,
149
- card: read.paymentMethod === null ? null : { brand: read.paymentMethod.brand, last4: read.paymentMethod.last4 },
150
- },
151
- portalAvailable: true,
152
- unreadable: read.unreadable,
153
- };
154
- }
155
-
156
- /** The member's purchase leads as History rows (#11096 D9) — no receipt; a 401, 403 or 404 is none. */
157
- async function loadPurchaseHistory(init: { headers: Record<string, string> }): Promise<BillingHistoryState> {
158
- try {
159
- const res = await member.purchases(init);
160
- if (res.ok) return { kind: "items", items: res.body.items.map(purchaseRow) };
161
- if (NOTHING_TO_SHOW_STATUSES.has(res.status)) return NO_HISTORY;
162
- console.error(`[account] read failed source=purchases status=${res.status}`);
163
- return { kind: "failed" };
164
- } catch (err) {
165
- logReadFailure("purchases", err);
166
- return { kind: "failed" };
167
- }
168
- }
169
-
170
- /** The spec 8217 fallback: the spoke's own key for the plan, the purchase leads for History. */
171
- async function loadSpokeFallback(init: { headers: Record<string, string> }): Promise<BillingRead> {
172
- const [state, history] = await Promise.all([loadSpokeBillingState(), loadPurchaseHistory(init)]);
173
- return { state, history };
174
- }
175
-
176
- /** A hub-mode spoke's Billing (#11165): the hub's read first, the spoke's own key as the fallback. */
177
- async function loadHubBilling(init: { headers: Record<string, string> }): Promise<BillingRead> {
178
- let res: Awaited<ReturnType<typeof member.billing>>;
179
- try {
180
- res = await member.billing(init);
181
- } catch (err) {
182
- logReadFailure("billing", err);
183
- return FAILED;
184
- }
185
- if (!res.ok) {
186
- if (NOTHING_TO_SHOW_STATUSES.has(res.status)) return loadSpokeFallback(init);
187
- console.error(`[account] read failed source=billing status=${res.status}`);
188
- return FAILED;
189
- }
190
- // The hub's body is re-parsed here, so a receipt page the History links is
191
- // a Stripe-hosted https: URL whatever answered (SEC-11165: the hub is the
192
- // producer, never the spoke's trust anchor).
193
- const parsed = memberBillingResponseSchema.safeParse(res.body);
194
- if (!parsed.success) {
195
- console.error("[account] read failed source=billing outcome=invalid_body");
196
- return FAILED;
197
- }
198
- const billing = parsed.data.billing;
199
- if (billing === undefined || billing.source === "none") return loadSpokeFallback(init);
200
- if (billing.source === "failed") {
201
- console.error("[account] read failed source=billing outcome=hub_read_failed");
202
- return FAILED;
203
- }
204
- const state: BillingState =
205
- billing.plan === null
206
- ? { kind: "none", unreadable: false }
207
- : { kind: "subscription", plan: billing.plan, portalAvailable: billing.portalAvailable, unreadable: false };
208
- const history =
209
- billing.history.length > 0
210
- ? { kind: "items" as const, items: billing.history }
211
- : await loadPurchaseHistory(init);
212
- return { state, history };
213
- }
214
-
215
- export async function loadBilling(init: { headers: Record<string, string> }): Promise<BillingRead> {
216
- if (SIGN_IN_PROVIDER === "hub") return loadHubBilling(init);
217
- try {
218
- const res = await subscription.me(init, { include: "billing" });
219
- if (!res.ok) {
220
- if (NOTHING_TO_SHOW_STATUSES.has(res.status)) {
221
- return { state: { kind: "none", unreadable: false }, history: NO_HISTORY };
222
- }
223
- console.error(`[account] read failed source=billing status=${res.status}`);
224
- return { state: { kind: "failed" }, history: NO_HISTORY };
225
- }
226
- const sub = res.body;
227
- if (sub.status === null) return { state: { kind: "none", unreadable: false }, history: NO_HISTORY };
228
- const card = sub.paymentMethod ?? null;
229
- return {
230
- state: {
231
- kind: "subscription",
232
- plan: {
233
- name: sub.planName ?? null,
234
- status: sub.status,
235
- price: null,
236
- renewsAt: null,
237
- accessEndsAt: sub.accessRevokesAt,
238
- card: card === null ? null : { brand: card.brand, last4: card.last4 },
239
- },
240
- portalAvailable: sub.portalAvailable,
241
- unreadable: false,
242
- },
243
- history: NO_HISTORY,
244
- };
245
- } catch (err) {
246
- logReadFailure("billing", err);
247
- return { state: { kind: "failed" }, history: NO_HISTORY };
248
- }
249
- }
250
-
251
- /** The shown set's share of Billing (#11165): the base plan, the Upgrade target and the offer. */
252
- export async function loadBillingOfferings(): Promise<BillingOfferings> {
253
- const read = await readShownOfferings();
254
- return read.kind === "shown" ? billingOfferings(read.shownSet) : NO_BILLING_OFFERINGS;
255
- }
256
-
257
- /**
258
- * The caller's Stripe billing-portal URL, or `null` for no portal (#8217
259
- * D10; #11165). Minted on a Manage click, never on render: on a hub-mode
260
- * spoke from the hub's member portal route, else — a 404 there — from the
261
- * spoke's own key (a loader that fails to load is `null`); otherwise from
262
- * the hub's portal route — `null` on a non-2xx or a throw, logged with the
263
- * status or `err.name` only.
264
- */
265
- export async function billingPortalUrl(): Promise<string | null> {
266
- const init = await forwardedCookieInit();
267
- if (SIGN_IN_PROVIDER === "hub") {
268
- try {
269
- const res = await member.billingPortal(init);
270
- if (res.ok) {
271
- // Re-parsed before the redirect: a Stripe-hosted https: URL or nothing.
272
- const url = memberBillingPortalResponseSchema.safeParse(res.body);
273
- if (url.success) return url.data.url;
274
- console.error("[openBillingPortal] source=member-billing outcome=invalid_body");
275
- return null;
276
- }
277
- if (res.status !== 404) {
278
- console.error(`[openBillingPortal] source=member-billing status=${res.status}`);
279
- return null;
280
- }
281
- } catch (err) {
282
- console.error(`[openBillingPortal] source=member-billing errName=${errorName(err)}`);
283
- return null;
284
- }
285
- try {
286
- return (await (await loadSpokeBilling())?.portalUrl()) ?? null;
287
- } catch (err) {
288
- console.error(`[openBillingPortal] source=spoke-billing errName=${errorName(err)}`);
289
- return null;
290
- }
291
- }
292
- try {
293
- const res = await subscription.portalSession(init);
294
- if (!res.ok) {
295
- console.error(`[openBillingPortal] status=${res.status}`);
296
- return null;
297
- }
298
- return res.body.url;
299
- } catch (err) {
300
- console.error(`[openBillingPortal] errName=${errorName(err)}`);
301
- return null;
302
- }
303
- }
@@ -1,274 +0,0 @@
1
- "use client"; // reads the request form on open and posts a controlled form
2
-
3
- /**
4
- * RequestQuote — the New menu's Request quote popup (#8233, spec D5, D7,
5
- * D10; roadmap D5). It renders the request-quote magnet's CURRENT steps:
6
- * the form is read each time the popup opens (`readRequestForm`), so a step
7
- * the provider adds in the Admin shows on the next open. `form: null` —
8
- * Request quote switched off since the menu loaded — says so, with no form.
9
- *
10
- * Every field of every served step renders in order (the server checks
11
- * every one, and evaluates no `showIf`), its copy resolved from the
12
- * provider's `LocalizedString`s and rendered as text, never markup. Only
13
- * the seven input types the server answers render; a step title is a heading
14
- * only when there is more than one step. Each control posts as
15
- * `answer.<name>`; a blank optional answer is omitted by the action. No
16
- * identity field is added — the server takes the name and email from the
17
- * session; a field shows only because the provider's form asks it.
18
- *
19
- * Controlled, posting what the state holds, so a refusal keeps every answer.
20
- * The link is sent as typed (`inputMode="url"`, no browser URL check): the
21
- * server's https rule is the only one, and its `link_not_https` refusal
22
- * shows INLINE under the link field whose value is not https (#11155). A
23
- * `date` field (#11155) is a `DateInput` whose `min` is the member's own
24
- * today; the server's rule (an ISO date not before today) is the one that
25
- * counts.
26
- */
27
-
28
- import {
29
- Button,
30
- DateInput,
31
- Heading,
32
- InlineMessage,
33
- Input,
34
- Label,
35
- Select,
36
- SelectContent,
37
- SelectItem,
38
- SelectTrigger,
39
- SelectValue,
40
- Text,
41
- Textarea,
42
- toIsoDate,
43
- } from "@working-theory/ui/primitives";
44
- import {
45
- resolveLocalizedString,
46
- type MemberRequestFormResponse,
47
- } from "@working-theory/validation";
48
- import {
49
- startTransition,
50
- useActionState,
51
- useId,
52
- useState,
53
- type FormEvent,
54
- type ReactElement,
55
- } from "react";
56
-
57
- import { readRequestForm, requestQuote, type NewActionState } from "../new-actions";
58
- import {
59
- NewPopupRefusal,
60
- NewPopupStatus,
61
- useNewMenuPopup,
62
- useOpenRead,
63
- type NewPopupLabels,
64
- } from "../new-menu";
65
-
66
- type RequestForm = NonNullable<MemberRequestFormResponse["form"]>;
67
- type FormField = RequestForm["steps"][number]["fields"][number];
68
-
69
- /** The input types the requests write answers (`ANSWERABLE`, 8170; `date` #11155). */
70
- const RENDERED = new Set(["text", "email", "tel", "textarea", "select", "url", "date"]);
71
-
72
- export interface RequestQuoteLabels extends NewPopupLabels {
73
- submit: string;
74
- /** The date picker button's accessible name. */
75
- pickDate: string;
76
- }
77
-
78
- export interface RequestQuoteProps {
79
- locale: string;
80
- labels: RequestQuoteLabels;
81
- }
82
-
83
- export function RequestQuote({ locale, labels }: RequestQuoteProps): ReactElement {
84
- const [read, retry] = useOpenRead(readRequestForm);
85
- if (read === "loading" || read.kind === "error") {
86
- return <NewPopupStatus failed={read !== "loading"} labels={labels} onRetry={retry} />;
87
- }
88
- if (read.form === null) {
89
- return (
90
- <Text as="p" variant="body-sm" data-testid="new-quote-off">
91
- {labels.errors.request_form_off}
92
- </Text>
93
- );
94
- }
95
- return <RequestQuoteForm form={read.form} locale={locale} labels={labels} />;
96
- }
97
-
98
- function RequestQuoteForm({
99
- form,
100
- locale,
101
- labels,
102
- }: {
103
- form: RequestForm;
104
- locale: string;
105
- labels: RequestQuoteLabels;
106
- }): ReactElement {
107
- const popup = useNewMenuPopup();
108
- const id = useId();
109
- const [answers, setAnswers] = useState<Record<string, string>>({});
110
- const [state, dispatch, pending] = useActionState<NewActionState, FormData>(
111
- async (prev, formData) => {
112
- const next = await requestQuote(prev, formData);
113
- if (next.kind === "success") popup.close(true);
114
- return next;
115
- },
116
- { kind: "idle" },
117
- );
118
-
119
- const text = (value: Record<string, string>): string =>
120
- resolveLocalizedString(value, locale, form.defaultLocale);
121
- const setAnswer = (name: string, value: string): void =>
122
- setAnswers((current) => ({ ...current, [name]: value }));
123
-
124
- const onSubmit = (event: FormEvent<HTMLFormElement>): void => {
125
- event.preventDefault();
126
- const formData = new FormData();
127
- for (const [name, value] of Object.entries(answers)) formData.set(`answer.${name}`, value);
128
- startTransition(() => dispatch(formData));
129
- };
130
-
131
- // A `link_not_https` refusal belongs to the link field(s) whose value is
132
- // not https; with none to pin it on (the server's rule is stricter than
133
- // this prefix check), it shows as the form's refusal instead.
134
- const offendingLinks =
135
- state.kind === "error" && state.code === "link_not_https"
136
- ? form.steps
137
- .flatMap((step) => step.fields)
138
- .filter((field) => {
139
- const value = answers[field.name] ?? "";
140
- return field.inputType === "url" && value.trim() !== "" && !value.startsWith("https://");
141
- })
142
- .map((field) => field.name)
143
- : [];
144
- const formRefusal = state.kind === "error" && offendingLinks.length === 0 ? state.code : null;
145
- // The member's own calendar day — the date input's `min`.
146
- const today = toIsoDate(new Date());
147
-
148
- const renderField = (field: FormField): ReactElement | null => {
149
- if (!RENDERED.has(field.inputType)) return null;
150
- const controlId = `${id}-${field.name}`;
151
- const helpId = `${controlId}-help`;
152
- const errorId = `${controlId}-error`;
153
- const help = field.copy.help ? text(field.copy.help) : null;
154
- const error = offendingLinks.includes(field.name) ? labels.errors.link_not_https : null;
155
- const describedBy = [help ? helpId : null, error ? errorId : null].filter(Boolean).join(" ");
156
- const value = answers[field.name] ?? "";
157
- const common = {
158
- id: controlId,
159
- name: `answer.${field.name}`,
160
- required: field.required === true,
161
- ...(describedBy ? { "aria-describedby": describedBy } : {}),
162
- ...(error ? { "aria-invalid": true as const } : {}),
163
- "data-testid": `new-quote-field-${field.name}`,
164
- };
165
- const placeholder = field.copy.placeholder ? text(field.copy.placeholder) : undefined;
166
- const onChange = (event: { target: { value: string } }): void =>
167
- setAnswer(field.name, event.target.value);
168
-
169
- let control: ReactElement;
170
- if (field.inputType === "textarea") {
171
- control = (
172
- <Textarea {...common} rows={4} value={value} placeholder={placeholder} onChange={onChange} />
173
- );
174
- } else if (field.inputType === "select") {
175
- control = (
176
- <Select
177
- name={common.name}
178
- required={common.required}
179
- value={value}
180
- onValueChange={(next) => setAnswer(field.name, next)}
181
- >
182
- <SelectTrigger
183
- id={controlId}
184
- {...(describedBy ? { "aria-describedby": describedBy } : {})}
185
- data-testid={common["data-testid"]}
186
- >
187
- <SelectValue {...(placeholder ? { placeholder } : {})} />
188
- </SelectTrigger>
189
- <SelectContent>
190
- {(field.options ?? []).map((option) => (
191
- <SelectItem key={option.value} value={option.value}>
192
- {text(option.label)}
193
- </SelectItem>
194
- ))}
195
- </SelectContent>
196
- </Select>
197
- );
198
- } else if (field.inputType === "date") {
199
- control = (
200
- <DateInput
201
- {...common}
202
- value={value}
203
- min={today}
204
- pickerLabel={labels.pickDate}
205
- onValueChange={(next) => setAnswer(field.name, next)}
206
- />
207
- );
208
- } else {
209
- control = (
210
- <Input
211
- {...common}
212
- // A url field takes text: no browser URL check, so the server's plain refusal is the rule.
213
- type={field.inputType === "url" ? "text" : field.inputType}
214
- {...(field.inputType === "url" ? { inputMode: "url" as const } : {})}
215
- value={value}
216
- placeholder={placeholder}
217
- onChange={onChange}
218
- />
219
- );
220
- }
221
-
222
- return (
223
- <div key={field.name} className="flex flex-col gap-2">
224
- <div className="flex items-baseline gap-2">
225
- <Label htmlFor={controlId}>{text(field.copy.label)}</Label>
226
- {field.required ? null : (
227
- <Text as="span" variant="caption">
228
- {labels.optional}
229
- </Text>
230
- )}
231
- </div>
232
- {control}
233
- {help ? (
234
- <Text as="p" id={helpId} variant="caption">
235
- {help}
236
- </Text>
237
- ) : null}
238
- {error ? (
239
- <InlineMessage id={errorId} variant="error" data-testid={`new-quote-field-${field.name}-error`}>
240
- {error}
241
- </InlineMessage>
242
- ) : null}
243
- </div>
244
- );
245
- };
246
-
247
- const titled = form.steps.length > 1;
248
- return (
249
- <form onSubmit={onSubmit} className="flex flex-col gap-4" data-testid="new-quote-form">
250
- {form.steps.map((step) => (
251
- <div key={step.key} className="flex flex-col gap-4">
252
- {titled ? (
253
- <Heading level={3} visual={4} className="!text-body font-semibold">
254
- {text(step.copy.title)}
255
- </Heading>
256
- ) : null}
257
- {step.fields.map(renderField)}
258
- </div>
259
- ))}
260
- {formRefusal ? <NewPopupRefusal code={formRefusal} labels={labels} /> : null}
261
- <div>
262
- <Button
263
- type="submit"
264
- disabled={pending}
265
- // 44px on a phone (a touch-first context); the 36px primary from md up.
266
- className="max-md:min-h-11"
267
- data-testid="new-quote-submit"
268
- >
269
- {pending ? labels.submitting : labels.submit}
270
- </Button>
271
- </div>
272
- </form>
273
- );
274
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * ErrorRow — the account area's "a read failed" row (#7430, spec 7423 D12):
3
- * the message and a Retry control, inside the same bordered row box the
4
- * Inbox list uses. Never an empty list in its place.
5
- */
6
-
7
- import { RowGroup } from "@working-theory/ui/blocks";
8
- import { InlineMessage } from "@working-theory/ui/primitives";
9
- import type { ReactElement } from "react";
10
-
11
- import { RetryButton } from "./retry-button";
12
-
13
- export function ErrorRow({
14
- message,
15
- retryLabel,
16
- className,
17
- }: {
18
- message: string;
19
- retryLabel: string;
20
- className?: string;
21
- }): ReactElement {
22
- return (
23
- <RowGroup aria-label={message} {...(className ? { className } : {})}>
24
- <li
25
- className="flex flex-wrap items-center justify-between gap-3 px-4 py-3"
26
- data-testid="inbox-error"
27
- >
28
- <InlineMessage variant="error" className="text-body-sm">
29
- {message}
30
- </InlineMessage>
31
- <RetryButton label={retryLabel} />
32
- </li>
33
- </RowGroup>
34
- );
35
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * for-you-labels.ts — the For-you panel's strings from the `account`
3
- * namespace (#7430, spec §5.2 i18n), and the frame's persist key. Shared by
4
- * the layout's aside and the Inbox's phone For you tab.
5
- */
6
-
7
- import type { AccountTranslate, ForYouLabels } from "@working-theory/templates/account";
8
-
9
- /**
10
- * The account frame's `persistKey`: the shell's remembered collapse
11
- * (`ailk:shell:account:*`) and the For-you dismissals
12
- * (`ailk:account:foryou:dismissed`), shared by the aside and the Inbox's
13
- * phone For you tab so a dismissal holds on both.
14
- */
15
- export const ACCOUNT_PERSIST_KEY = "account";
16
-
17
- export function forYouLabels(t: AccountTranslate): ForYouLabels {
18
- return {
19
- title: t("forYou.title"),
20
- filter: t("forYou.filter"),
21
- allTypes: t("forYou.allTypes"),
22
- sort: t("forYou.sort"),
23
- mostRelevant: t("forYou.mostRelevant"),
24
- mostRecent: t("forYou.mostRecent"),
25
- view: t("forYou.view"),
26
- open: t("forYou.open"),
27
- dismiss: t("forYou.dismiss"),
28
- whyItMatters: t("forYou.whyItMatters"),
29
- expectedOutcome: t("forYou.expectedOutcome"),
30
- // The panel fills `{duration}` itself, so the placeholder passes through.
31
- waiting: t("forYou.waiting", { duration: "{duration}" }),
32
- empty: t("forYou.empty"),
33
- showAll: t("forYou.showAll"),
34
- close: t("forYou.close"),
35
- };
36
- }