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.
- package/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
"use client"; // the menu, the dialog and the top-bar portal hold client state
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* NewMenu — the member area's New button over the Inbox (#8233, spec
|
|
5
|
-
* docs/specs/8233-member-new-menu-the-new-spec.md D3, D5, D10; brief Layout
|
|
6
|
-
* item 3). Copied from the Admin's NewMenu idiom (apps do not import apps).
|
|
7
|
-
*
|
|
8
|
-
* Its rows are the contributed New actions the Inbox page found offered
|
|
9
|
-
* (`accountNewActions`, each already gated by its own member read). A row is
|
|
10
|
-
* a menu item: it opens that action's popup in one dialog over the Inbox, or
|
|
11
|
-
* — an action with `href` (#11154: Schedule appointment; #11152: Send
|
|
12
|
-
* message, to the member thread page) — navigates to that account page. With
|
|
13
|
-
* no action offered there is no menu at all.
|
|
14
|
-
*
|
|
15
|
-
* Two triggers share the dialog: the desktop New in the page's header row
|
|
16
|
-
* (`md` up), and a compact + the frame's phone top bar holds. The frame hands
|
|
17
|
-
* the top-bar node down through `NewMenuSlotProvider` on the Inbox route
|
|
18
|
-
* only; outside a frame (a test, a story) the node is null and only the
|
|
19
|
-
* desktop trigger renders.
|
|
20
|
-
*
|
|
21
|
-
* A popup body talks back through `useNewMenuPopup()`: `close(true)` after a
|
|
22
|
-
* successful write closes the dialog and refreshes the Inbox, `open(id)`
|
|
23
|
-
* switches to another offered action. A popup that reads on open uses
|
|
24
|
-
* `useOpenRead` and `NewPopupStatus`, so loading, a failed read and its retry
|
|
25
|
-
* look the same in every popup (D5).
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import {
|
|
29
|
-
Button,
|
|
30
|
-
Dialog,
|
|
31
|
-
DialogContent,
|
|
32
|
-
DialogHeader,
|
|
33
|
-
DialogTitle,
|
|
34
|
-
DropdownMenu,
|
|
35
|
-
DropdownMenuContent,
|
|
36
|
-
DropdownMenuItem,
|
|
37
|
-
DropdownMenuTrigger,
|
|
38
|
-
Icon,
|
|
39
|
-
InlineMessage,
|
|
40
|
-
Text,
|
|
41
|
-
} from "@working-theory/ui/primitives";
|
|
42
|
-
import { ChevronDown, Plus } from "lucide-react";
|
|
43
|
-
import { useRouter } from "next/navigation";
|
|
44
|
-
import {
|
|
45
|
-
createContext,
|
|
46
|
-
useCallback,
|
|
47
|
-
useContext,
|
|
48
|
-
useEffect,
|
|
49
|
-
useMemo,
|
|
50
|
-
useRef,
|
|
51
|
-
useState,
|
|
52
|
-
type ReactElement,
|
|
53
|
-
type ReactNode,
|
|
54
|
-
} from "react";
|
|
55
|
-
import { createPortal } from "react-dom";
|
|
56
|
-
|
|
57
|
-
import type { NewActionErrorCode } from "./new-actions";
|
|
58
|
-
|
|
59
|
-
/** One offered action, its label already translated: a popup, or a page to navigate to (#11154). */
|
|
60
|
-
export interface NewMenuAction {
|
|
61
|
-
id: string;
|
|
62
|
-
label: string;
|
|
63
|
-
popup?: ReactNode;
|
|
64
|
-
/** The localized path the row navigates to; such a row has no popup. */
|
|
65
|
-
href?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface NewMenuLabels {
|
|
69
|
-
trigger: string;
|
|
70
|
-
close: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** The strings every popup shares (D10, D11). */
|
|
74
|
-
export interface NewPopupLabels {
|
|
75
|
-
loading: string;
|
|
76
|
-
loadFailed: string;
|
|
77
|
-
retry: string;
|
|
78
|
-
submitting: string;
|
|
79
|
-
optional: string;
|
|
80
|
-
errors: Record<NewActionErrorCode, string>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ── The top-bar slot ─────────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
const NewMenuSlotContext = createContext<HTMLElement | null>(null);
|
|
86
|
-
|
|
87
|
-
/** Hands the phone top bar's trailing node to the page; `null` where the bar has none. */
|
|
88
|
-
export function NewMenuSlotProvider({
|
|
89
|
-
node,
|
|
90
|
-
children,
|
|
91
|
-
}: {
|
|
92
|
-
node: HTMLElement | null;
|
|
93
|
-
children: ReactNode;
|
|
94
|
-
}): ReactElement {
|
|
95
|
-
return <NewMenuSlotContext.Provider value={node}>{children}</NewMenuSlotContext.Provider>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function useNewMenuSlot(): HTMLElement | null {
|
|
99
|
-
return useContext(NewMenuSlotContext);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// ── The popup API ────────────────────────────────────────────────────────────
|
|
103
|
-
|
|
104
|
-
export interface NewMenuPopupApi {
|
|
105
|
-
/** Closes the dialog; after a successful write, also refreshes the Inbox. */
|
|
106
|
-
close(submitted: boolean): void;
|
|
107
|
-
/** Switches the dialog to another offered action. */
|
|
108
|
-
open(id: string): void;
|
|
109
|
-
/** Whether an action is offered. */
|
|
110
|
-
has(id: string): boolean;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const INERT_POPUP_API: NewMenuPopupApi = {
|
|
114
|
-
close: () => undefined,
|
|
115
|
-
open: () => undefined,
|
|
116
|
-
has: () => false,
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const NewMenuPopupContext = createContext<NewMenuPopupApi>(INERT_POPUP_API);
|
|
120
|
-
|
|
121
|
-
export function useNewMenuPopup(): NewMenuPopupApi {
|
|
122
|
-
return useContext(NewMenuPopupContext);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ── The menu ─────────────────────────────────────────────────────────────────
|
|
126
|
-
|
|
127
|
-
function ActionMenu({
|
|
128
|
-
compact,
|
|
129
|
-
actions,
|
|
130
|
-
label,
|
|
131
|
-
onPick,
|
|
132
|
-
onNavigate,
|
|
133
|
-
}: {
|
|
134
|
-
compact: boolean;
|
|
135
|
-
actions: readonly NewMenuAction[];
|
|
136
|
-
label: string;
|
|
137
|
-
onPick: (id: string, trigger: HTMLElement | null) => void;
|
|
138
|
-
onNavigate: (href: string) => void;
|
|
139
|
-
}): ReactElement {
|
|
140
|
-
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
141
|
-
// A pick hands focus to the dialog, so the closing menu must not take it back.
|
|
142
|
-
const picked = useRef(false);
|
|
143
|
-
return (
|
|
144
|
-
<DropdownMenu>
|
|
145
|
-
<DropdownMenuTrigger asChild>
|
|
146
|
-
{compact ? (
|
|
147
|
-
<Button
|
|
148
|
-
ref={triggerRef}
|
|
149
|
-
variant="ghost"
|
|
150
|
-
size="big"
|
|
151
|
-
iconOnly
|
|
152
|
-
aria-label={label}
|
|
153
|
-
className="size-11 rounded-full"
|
|
154
|
-
data-testid="account-new-menu-trigger-compact"
|
|
155
|
-
>
|
|
156
|
-
<Icon icon={Plus} size="md" decorative />
|
|
157
|
-
</Button>
|
|
158
|
-
) : (
|
|
159
|
-
<Button
|
|
160
|
-
ref={triggerRef}
|
|
161
|
-
variant="default"
|
|
162
|
-
className="hidden gap-1 md:inline-flex"
|
|
163
|
-
data-testid="account-new-menu-trigger"
|
|
164
|
-
>
|
|
165
|
-
<Icon icon={Plus} size="sm" decorative />
|
|
166
|
-
{label}
|
|
167
|
-
<Icon icon={ChevronDown} size="sm" decorative />
|
|
168
|
-
</Button>
|
|
169
|
-
)}
|
|
170
|
-
</DropdownMenuTrigger>
|
|
171
|
-
<DropdownMenuContent
|
|
172
|
-
align="end"
|
|
173
|
-
className="min-w-56"
|
|
174
|
-
onCloseAutoFocus={(event) => {
|
|
175
|
-
if (picked.current) event.preventDefault();
|
|
176
|
-
picked.current = false;
|
|
177
|
-
}}
|
|
178
|
-
data-testid="account-new-menu-content"
|
|
179
|
-
>
|
|
180
|
-
{actions.map((action) => (
|
|
181
|
-
<DropdownMenuItem
|
|
182
|
-
key={action.id}
|
|
183
|
-
onSelect={() => {
|
|
184
|
-
// A link row navigates and leaves focus to the next page (#11154).
|
|
185
|
-
if (action.href !== undefined) {
|
|
186
|
-
onNavigate(action.href);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
picked.current = true;
|
|
190
|
-
onPick(action.id, triggerRef.current);
|
|
191
|
-
}}
|
|
192
|
-
{...(action.href !== undefined ? { "data-href": action.href } : {})}
|
|
193
|
-
data-testid={`account-new-menu-item-${action.id}`}
|
|
194
|
-
>
|
|
195
|
-
{action.label}
|
|
196
|
-
</DropdownMenuItem>
|
|
197
|
-
))}
|
|
198
|
-
</DropdownMenuContent>
|
|
199
|
-
</DropdownMenu>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function NewMenu({
|
|
204
|
-
actions,
|
|
205
|
-
labels,
|
|
206
|
-
}: {
|
|
207
|
-
actions: readonly NewMenuAction[];
|
|
208
|
-
labels: NewMenuLabels;
|
|
209
|
-
}): ReactElement | null {
|
|
210
|
-
const router = useRouter();
|
|
211
|
-
const slot = useNewMenuSlot();
|
|
212
|
-
const [openId, setOpenId] = useState<string | null>(null);
|
|
213
|
-
// The trigger that opened the dialog gets focus back when it closes.
|
|
214
|
-
const returnFocus = useRef<HTMLElement | null>(null);
|
|
215
|
-
|
|
216
|
-
const api = useMemo<NewMenuPopupApi>(() => {
|
|
217
|
-
const has = (id: string): boolean => actions.some((action) => action.id === id);
|
|
218
|
-
return {
|
|
219
|
-
close(submitted) {
|
|
220
|
-
setOpenId(null);
|
|
221
|
-
if (submitted) router.refresh();
|
|
222
|
-
},
|
|
223
|
-
open(id) {
|
|
224
|
-
if (has(id)) setOpenId(id);
|
|
225
|
-
},
|
|
226
|
-
has,
|
|
227
|
-
};
|
|
228
|
-
}, [actions, router]);
|
|
229
|
-
|
|
230
|
-
if (actions.length === 0) return null;
|
|
231
|
-
|
|
232
|
-
const current = actions.find((action) => action.id === openId) ?? null;
|
|
233
|
-
const onPick = (id: string, trigger: HTMLElement | null): void => {
|
|
234
|
-
returnFocus.current = trigger;
|
|
235
|
-
setOpenId(id);
|
|
236
|
-
};
|
|
237
|
-
const onNavigate = (href: string): void => router.push(href);
|
|
238
|
-
|
|
239
|
-
return (
|
|
240
|
-
<>
|
|
241
|
-
<ActionMenu
|
|
242
|
-
compact={false}
|
|
243
|
-
actions={actions}
|
|
244
|
-
label={labels.trigger}
|
|
245
|
-
onPick={onPick}
|
|
246
|
-
onNavigate={onNavigate}
|
|
247
|
-
/>
|
|
248
|
-
{slot
|
|
249
|
-
? createPortal(
|
|
250
|
-
<ActionMenu
|
|
251
|
-
compact
|
|
252
|
-
actions={actions}
|
|
253
|
-
label={labels.trigger}
|
|
254
|
-
onPick={onPick}
|
|
255
|
-
onNavigate={onNavigate}
|
|
256
|
-
/>,
|
|
257
|
-
slot,
|
|
258
|
-
)
|
|
259
|
-
: null}
|
|
260
|
-
<Dialog
|
|
261
|
-
open={current !== null}
|
|
262
|
-
onOpenChange={(open) => {
|
|
263
|
-
if (!open) setOpenId(null);
|
|
264
|
-
}}
|
|
265
|
-
>
|
|
266
|
-
{current ? (
|
|
267
|
-
<DialogContent
|
|
268
|
-
closeLabel={labels.close}
|
|
269
|
-
aria-describedby={undefined}
|
|
270
|
-
onCloseAutoFocus={(event) => {
|
|
271
|
-
const trigger = returnFocus.current;
|
|
272
|
-
if (trigger?.isConnected) {
|
|
273
|
-
event.preventDefault();
|
|
274
|
-
trigger.focus();
|
|
275
|
-
}
|
|
276
|
-
}}
|
|
277
|
-
data-testid="account-new-popup"
|
|
278
|
-
>
|
|
279
|
-
<DialogHeader>
|
|
280
|
-
<DialogTitle>{current.label}</DialogTitle>
|
|
281
|
-
</DialogHeader>
|
|
282
|
-
<NewMenuPopupContext.Provider value={api}>
|
|
283
|
-
{/* Keyed, so switching actions mounts a fresh popup that reads anew. */}
|
|
284
|
-
<div key={current.id} className="mt-block-tight">
|
|
285
|
-
{current.popup}
|
|
286
|
-
</div>
|
|
287
|
-
</NewMenuPopupContext.Provider>
|
|
288
|
-
</DialogContent>
|
|
289
|
-
) : null}
|
|
290
|
-
</Dialog>
|
|
291
|
-
</>
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// ── Shared popup parts (D5, D10) ─────────────────────────────────────────────
|
|
296
|
-
|
|
297
|
-
export type OpenRead<T> = "loading" | { kind: "error" } | ({ kind: "ok" } & T);
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Reads a popup's data when it mounts — the dialog mounts a popup only while
|
|
301
|
-
* it is open, so this is a read per open (D5) — and returns a retry.
|
|
302
|
-
*/
|
|
303
|
-
export function useOpenRead<T>(
|
|
304
|
-
read: () => Promise<{ kind: "error" } | ({ kind: "ok" } & T)>,
|
|
305
|
-
): [OpenRead<T>, () => void] {
|
|
306
|
-
const [state, setState] = useState<OpenRead<T>>("loading");
|
|
307
|
-
// Only the newest read lands: a retry never loses to the read it replaced.
|
|
308
|
-
const latest = useRef(0);
|
|
309
|
-
const load = useCallback(() => {
|
|
310
|
-
const readId = ++latest.current;
|
|
311
|
-
const land = (next: OpenRead<T>): void => {
|
|
312
|
-
if (readId === latest.current) setState(next);
|
|
313
|
-
};
|
|
314
|
-
setState("loading");
|
|
315
|
-
read().then(land, () => land({ kind: "error" }));
|
|
316
|
-
}, [read]);
|
|
317
|
-
useEffect(load, [load]);
|
|
318
|
-
return [state, load];
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/** A popup's loading line, or its failed-read line with Try again. */
|
|
322
|
-
export function NewPopupStatus({
|
|
323
|
-
failed,
|
|
324
|
-
labels,
|
|
325
|
-
onRetry,
|
|
326
|
-
}: {
|
|
327
|
-
failed: boolean;
|
|
328
|
-
labels: NewPopupLabels;
|
|
329
|
-
onRetry: () => void;
|
|
330
|
-
}): ReactElement {
|
|
331
|
-
if (!failed) {
|
|
332
|
-
return (
|
|
333
|
-
<div role="status" data-testid="new-popup-loading">
|
|
334
|
-
<Text as="p" variant="body-sm" tone="muted">
|
|
335
|
-
{labels.loading}
|
|
336
|
-
</Text>
|
|
337
|
-
</div>
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
return (
|
|
341
|
-
<div className="flex flex-wrap items-center gap-3" data-testid="new-popup-load-failed">
|
|
342
|
-
<InlineMessage variant="error" className="text-body-sm">
|
|
343
|
-
{labels.loadFailed}
|
|
344
|
-
</InlineMessage>
|
|
345
|
-
<Button variant="outline" onClick={onRetry} data-testid="new-popup-retry">
|
|
346
|
-
{labels.retry}
|
|
347
|
-
</Button>
|
|
348
|
-
</div>
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/** A refused write's plain message; the popup stays open with every value kept. */
|
|
353
|
-
export function NewPopupRefusal({
|
|
354
|
-
code,
|
|
355
|
-
labels,
|
|
356
|
-
}: {
|
|
357
|
-
code: NewActionErrorCode;
|
|
358
|
-
labels: NewPopupLabels;
|
|
359
|
-
}): ReactElement {
|
|
360
|
-
return (
|
|
361
|
-
<InlineMessage variant="error" data-testid="new-popup-error">
|
|
362
|
-
{labels.errors[code]}
|
|
363
|
-
</InlineMessage>
|
|
364
|
-
);
|
|
365
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* new-popups.tsx — the New menu's actions with their popups bound (#8233 D1,
|
|
3
|
-
* D2, D6–D8).
|
|
4
|
-
*
|
|
5
|
-
* `lib/account-config.ts` carries each action's server half — its id, its
|
|
6
|
-
* label and the member read that decides whether it is offered — and this
|
|
7
|
-
* file adds the popup each one opens, composing the `AccountNewAction`
|
|
8
|
-
* contract (`@working-theory/templates/account`) the Inbox page consumes.
|
|
9
|
-
*
|
|
10
|
-
* The split is create-ailk's spoke closure (`spokeExclusions`,
|
|
11
|
-
* `packages/create-ailk/src/topology.ts`): a spoke without sign-in drops the
|
|
12
|
-
* whole `(authed)` group, these popups included, and every file that imports
|
|
13
|
-
* one of them goes too — but `account-config.ts` is a shared lib file every
|
|
14
|
-
* spoke keeps, so it may import nothing under `(authed)` (the closure guard
|
|
15
|
-
* refuses the scaffold, naming it). This file sits inside the group: it goes
|
|
16
|
-
* with the popups on such a spoke, and stays with them on a hub-sign-in one
|
|
17
|
-
* and on a single site, where the page still renders all three.
|
|
18
|
-
*
|
|
19
|
-
* A popup receives only its locale and strings built through `ctx.t` — never
|
|
20
|
-
* `ctx`, its init, its user or `t` itself — so no credential or email reaches
|
|
21
|
-
* the client payload (SEC-8233-1). `popups` is keyed on the config's own id
|
|
22
|
-
* union, so a read added there without a popup here is a type error, never a
|
|
23
|
-
* menu row that opens nothing. A read carrying `href` is a link row and
|
|
24
|
-
* binds no popup: Schedule appointment (#11154) navigates to
|
|
25
|
-
* `/account/appointments`, the retired schedule popup's one booking path;
|
|
26
|
-
* Send message (#11152) navigates to `/account/inbox/thread`, the member's
|
|
27
|
-
* thread page, whose composer took over from the retired message lightbox.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import type {
|
|
31
|
-
AccountContext,
|
|
32
|
-
AccountNewAction,
|
|
33
|
-
AccountTranslate,
|
|
34
|
-
} from "@working-theory/templates/account";
|
|
35
|
-
import type { ReactNode } from "react";
|
|
36
|
-
|
|
37
|
-
import { accountNewActions } from "../../../../lib/account-config";
|
|
38
|
-
|
|
39
|
-
import { RequestQuote } from "./components/request-quote";
|
|
40
|
-
import type { NewActionErrorCode } from "./new-actions";
|
|
41
|
-
import type { NewPopupLabels } from "./new-menu";
|
|
42
|
-
|
|
43
|
-
/** Each refusal code's plain line — the popups' and the thread composer's (#11152) one map. */
|
|
44
|
-
export function newActionErrorLabels(t: AccountTranslate): Record<NewActionErrorCode, string> {
|
|
45
|
-
return {
|
|
46
|
-
link_not_https: t("new.errors.linkNotHttps"),
|
|
47
|
-
answers_invalid: t("new.errors.answersInvalid"),
|
|
48
|
-
request_form_off: t("new.errors.requestFormOff"),
|
|
49
|
-
meeting_type_not_offered: t("new.errors.meetingTypeNotOffered"),
|
|
50
|
-
slot_unavailable: t("new.errors.slotUnavailable"),
|
|
51
|
-
too_many_requests: t("new.errors.tooManyRequests"),
|
|
52
|
-
invalid_input: t("new.errors.invalidInput"),
|
|
53
|
-
failed: t("new.errors.failed"),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** The strings every popup shares — plain strings, so nothing else crosses to the client. */
|
|
58
|
-
function popupLabels(t: AccountTranslate): NewPopupLabels {
|
|
59
|
-
return {
|
|
60
|
-
loading: t("new.loading"),
|
|
61
|
-
loadFailed: t("new.loadFailed"),
|
|
62
|
-
retry: t("new.retry"),
|
|
63
|
-
submitting: t("new.submitting"),
|
|
64
|
-
optional: t("new.optional"),
|
|
65
|
-
errors: newActionErrorLabels(t),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** The ids of the reads that open a popup — every read without an `href` (#11154). */
|
|
70
|
-
type AccountNewPopupId = Exclude<(typeof accountNewActions)[number], { href: string }>["id"];
|
|
71
|
-
|
|
72
|
-
/** The popup each action opens, keyed on the config's ids (D6–D8). */
|
|
73
|
-
const popups = {
|
|
74
|
-
"request-quote": ({ locale, t }) => (
|
|
75
|
-
<RequestQuote
|
|
76
|
-
locale={locale}
|
|
77
|
-
labels={{ ...popupLabels(t), submit: t("new.quote.submit"), pickDate: t("new.quote.pickDate") }}
|
|
78
|
-
/>
|
|
79
|
-
),
|
|
80
|
-
} satisfies Record<AccountNewPopupId, (ctx: AccountContext) => ReactNode>;
|
|
81
|
-
|
|
82
|
-
/** The New actions in menu order (D2), each with its popup or its page — what the Inbox page offers. */
|
|
83
|
-
export const newActions: readonly AccountNewAction[] = accountNewActions.map(
|
|
84
|
-
(read): AccountNewAction =>
|
|
85
|
-
"href" in read ? read : { ...read, renderPopup: popups[read.id] },
|
|
86
|
-
);
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/account/notifications — User settings › Notifications (#8339
|
|
3
|
-
* D8; #8438 D15 — what we send you; #11163 — Ploy's three-row shape).
|
|
4
|
-
*
|
|
5
|
-
* RSC, outside the account layout's SignedInShell (#8430), in the member's
|
|
6
|
-
* settings frame (D7) — standalone, the Admin's shape. Always renders
|
|
7
|
-
* (decision A, operator 2026-10-12): a `ConsentSwitchList` of the site
|
|
8
|
-
* registry's `area: "communications"` purposes (`consent` and
|
|
9
|
-
* `preference`), each read from `GET /v1/member/consents`'s OWN state and
|
|
10
|
-
* `effective` default (no row ⇒ on for a preference, off for a consent).
|
|
11
|
-
* With none declared, one `account-notifications-empty` line.
|
|
12
|
-
*
|
|
13
|
-
* A row is a TITLE, a one-line description and a switch (#11163, operator
|
|
14
|
-
* 2026-11-08) — never the purpose's consent statement, which stays on the
|
|
15
|
-
* form that collects it and in the ledger. The three registry purposes the
|
|
16
|
-
* site ships are named by this app's own messages
|
|
17
|
-
* (`settings.notifications.purposes.<id>`): Email notifications ·
|
|
18
|
-
* Onboarding · Marketing, in registry order; a purpose a site adds is titled
|
|
19
|
-
* by its registry description. Under the rows one muted line says what is
|
|
20
|
-
* always sent.
|
|
21
|
-
*
|
|
22
|
-
* The cookie-settings link moved to Privacy (#8438 D14, C6) — this tab no
|
|
23
|
-
* longer renders it.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { member } from "@working-theory/api-client";
|
|
27
|
-
import {
|
|
28
|
-
AccountSettingsFrame,
|
|
29
|
-
AccountSettingsPane,
|
|
30
|
-
ConsentSwitchList,
|
|
31
|
-
type ConsentSwitchRow,
|
|
32
|
-
} from "@working-theory/templates/account";
|
|
33
|
-
import {
|
|
34
|
-
formatLocalTime,
|
|
35
|
-
SERVER_TIME_ZONE,
|
|
36
|
-
} from "@working-theory/ui/primitives";
|
|
37
|
-
import {
|
|
38
|
-
EMAIL_NOTIFICATIONS_PURPOSE_ID,
|
|
39
|
-
NEWSLETTER_PURPOSE_ID,
|
|
40
|
-
ONBOARDING_PURPOSE_ID,
|
|
41
|
-
} from "@working-theory/validation";
|
|
42
|
-
import type { Metadata } from "next";
|
|
43
|
-
import { getTranslations } from "next-intl/server";
|
|
44
|
-
import type { ReactElement } from "react";
|
|
45
|
-
|
|
46
|
-
import { accountSession } from "../account-data";
|
|
47
|
-
import { setConsentAction } from "../privacy/actions";
|
|
48
|
-
import { memberSettingsFrame, type Translate } from "../settings-frame";
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The registry purposes this app names itself (#11163): purpose id → the
|
|
52
|
-
* `settings.notifications.purposes` key carrying its title and line.
|
|
53
|
-
*/
|
|
54
|
-
const NAMED_PURPOSES = {
|
|
55
|
-
[EMAIL_NOTIFICATIONS_PURPOSE_ID]: "email_notifications",
|
|
56
|
-
[ONBOARDING_PURPOSE_ID]: "onboarding",
|
|
57
|
-
[NEWSLETTER_PURPOSE_ID]: "newsletter",
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
function isNamedPurpose(id: string): id is keyof typeof NAMED_PURPOSES {
|
|
61
|
-
return Object.prototype.hasOwnProperty.call(NAMED_PURPOSES, id);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface Props {
|
|
65
|
-
params: Promise<{ locale: string }>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
69
|
-
const { locale } = await params;
|
|
70
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
71
|
-
return { title: t("settings.notifications.title"), description: t("settings.notifications.lead") };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default async function AccountNotificationsPage({ params }: Props): Promise<ReactElement> {
|
|
75
|
-
const { locale } = await params;
|
|
76
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
77
|
-
const session = await accountSession(locale);
|
|
78
|
-
const frame = memberSettingsFrame(locale, t as unknown as Translate, "notifications");
|
|
79
|
-
const name = session?.ctx.user.name || session?.ctx.user.email || "";
|
|
80
|
-
|
|
81
|
-
let rows: ConsentSwitchRow[] = [];
|
|
82
|
-
let unavailable = false;
|
|
83
|
-
if (session) {
|
|
84
|
-
try {
|
|
85
|
-
const res = await member.consents(session.ctx.init, { locale });
|
|
86
|
-
if (res.ok) {
|
|
87
|
-
rows = res.body.purposes
|
|
88
|
-
.filter((purpose) => purpose.area === "communications")
|
|
89
|
-
.map((purpose) => ({
|
|
90
|
-
id: purpose.id,
|
|
91
|
-
...(isNamedPurpose(purpose.id)
|
|
92
|
-
? {
|
|
93
|
-
label: t(`settings.notifications.purposes.${NAMED_PURPOSES[purpose.id]}.title`),
|
|
94
|
-
description: t(
|
|
95
|
-
`settings.notifications.purposes.${NAMED_PURPOSES[purpose.id]}.description`,
|
|
96
|
-
),
|
|
97
|
-
}
|
|
98
|
-
: { label: purpose.description }),
|
|
99
|
-
granted: purpose.effective,
|
|
100
|
-
...(purpose.state
|
|
101
|
-
? {
|
|
102
|
-
dateLine: purpose.state.granted
|
|
103
|
-
? t("settings.privacy.given", { date: formatDate(purpose.state.at, locale) })
|
|
104
|
-
: t("settings.privacy.withdrawn", { date: formatDate(purpose.state.at, locale) }),
|
|
105
|
-
}
|
|
106
|
-
: {}),
|
|
107
|
-
}));
|
|
108
|
-
} else {
|
|
109
|
-
unavailable = true;
|
|
110
|
-
}
|
|
111
|
-
} catch {
|
|
112
|
-
unavailable = true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<AccountSettingsFrame {...frame} name={name}>
|
|
118
|
-
<AccountSettingsPane
|
|
119
|
-
id="account-settings-notifications"
|
|
120
|
-
title={t("settings.notifications.title")}
|
|
121
|
-
lead={t("settings.notifications.lead")}
|
|
122
|
-
>
|
|
123
|
-
{unavailable ? (
|
|
124
|
-
<span data-testid="account-notifications-unavailable">{t("settings.privacy.unavailable")}</span>
|
|
125
|
-
) : (
|
|
126
|
-
<ConsentSwitchList
|
|
127
|
-
rows={rows}
|
|
128
|
-
onChange={setConsentAction}
|
|
129
|
-
emptyLine={t("settings.notifications.empty")}
|
|
130
|
-
footLine={t("settings.notifications.alwaysSent")}
|
|
131
|
-
testIdPrefix="account-notifications"
|
|
132
|
-
/>
|
|
133
|
-
)}
|
|
134
|
-
</AccountSettingsPane>
|
|
135
|
-
</AccountSettingsFrame>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// #11159: a `t()` argument is a string, so this RSC reads the day in the
|
|
140
|
-
// server fallback zone — never the host's, which the unpinned form read.
|
|
141
|
-
function formatDate(iso: string, locale: string): string {
|
|
142
|
-
return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
|
|
143
|
-
}
|