create-ailk 0.35.1 → 0.37.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 (169) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +51 -1
  3. package/component-catalog.md +8 -5
  4. package/dist/lib/env-catalog.js +8 -0
  5. package/dist/surfaces.js +66 -22
  6. package/dist/topology.d.ts +4 -4
  7. package/dist/topology.js +104 -60
  8. package/dist/update.d.ts +19 -1
  9. package/dist/update.js +293 -35
  10. package/package.json +3 -3
  11. package/templates/.env.example +38 -0
  12. package/templates/apps/api/.env.example +45 -0
  13. package/templates/apps/api/CLAUDE.md +12 -4
  14. package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
  15. package/templates/apps/mcp/CLAUDE.md +4 -2
  16. package/templates/apps/web/.env.example +16 -0
  17. package/templates/apps/web/CLAUDE.md +73 -5
  18. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  19. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
  20. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
  21. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
  22. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  23. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  24. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  25. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  26. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  29. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  30. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +241 -66
  31. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
  32. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
  33. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
  34. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
  40. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
  41. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
  42. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
  43. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
  44. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
  45. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
  46. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
  47. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
  51. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
  53. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
  54. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
  55. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
  56. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
  57. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
  58. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
  59. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
  60. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
  61. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
  62. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
  63. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  64. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  65. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  66. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  67. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
  68. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
  69. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
  70. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
  71. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  72. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +215 -0
  73. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
  74. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
  75. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
  76. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
  77. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
  78. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
  79. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
  80. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
  81. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  82. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  83. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  84. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  85. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  86. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +9 -6
  87. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
  88. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
  89. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
  90. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
  91. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
  92. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
  93. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
  94. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
  95. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
  96. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
  97. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
  98. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
  99. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  100. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
  101. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  102. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  103. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
  104. package/templates/apps/web/app/[locale]/layout.tsx +24 -75
  105. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  106. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  107. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  108. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +166 -7
  109. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
  110. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  111. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  112. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  113. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
  114. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
  115. package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
  116. package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
  117. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  118. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  119. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  120. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  121. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +738 -7
  122. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  123. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  124. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  125. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  126. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  127. package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
  128. package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
  129. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  130. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  131. package/templates/apps/web/auth.ts +133 -6
  132. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  133. package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
  134. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  135. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  136. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  137. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  138. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
  139. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  140. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  141. package/templates/apps/web/lib/account-config.ts +132 -8
  142. package/templates/apps/web/lib/auth-email.ts +62 -6
  143. package/templates/apps/web/lib/auth-env.ts +13 -0
  144. package/templates/apps/web/lib/auth-routes.ts +11 -6
  145. package/templates/apps/web/lib/auth-sms.ts +180 -0
  146. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  147. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  148. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  149. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  150. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  151. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  152. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  153. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  154. package/templates/apps/web/lib/offerings-pricing.ts +4 -1
  155. package/templates/apps/web/lib/site-header.ts +14 -1
  156. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  157. package/templates/apps/web/lib/topology.generated.ts +39 -0
  158. package/templates/apps/web/messages/en.json +264 -96
  159. package/templates/apps/web/middleware.ts +34 -2
  160. package/templates/apps/web/security-headers.config.ts +21 -0
  161. package/versions.json +48 -48
  162. package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
  163. package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
  164. package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
  165. package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
  166. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  167. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  168. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  169. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -0,0 +1,154 @@
1
+ /**
2
+ * /[locale]/account/invitations/[invitationId] — accept an invitation to an
3
+ * organization (#11106, spec
4
+ * docs/specs/11106-the-workforce-foundation-roles-by-spec.md D5; AC-3).
5
+ *
6
+ * The mailed link is `/sign-in?next=/account/invitations/<id>&email=<address>`:
7
+ * a signed-out visitor lands on `/sign-in` with the invited address already
8
+ * filled, and this page sits under `(authed)`, whose gate redirects any other
9
+ * signed-out visit to `/sign-in?next=…`. Signed in, the page reads the
10
+ * invitation (`readInvitation`), which the API answers only for the invited,
11
+ * VERIFIED address:
12
+ *
13
+ * - pending: the organization, the inviter and the role, and Accept — a
14
+ * form POST to `acceptInvitation`, which creates the Membership and
15
+ * returns here with `?joined=1`. A GET of this page writes nothing;
16
+ * - another address: "This invitation is for a different email address.
17
+ * Sign out and sign in with the invited address.";
18
+ * - no such invitation, or a build without the invitation routes (404):
19
+ * `notFound()`;
20
+ * - accepted, expired or no longer open: one line saying so.
21
+ *
22
+ * After joining, the person reaches the Admin through its own sign-in, which
23
+ * now admits them. Every string is an `account.invitation.*` message.
24
+ */
25
+
26
+ import { Button, Container, Heading, InlineMessage, Text } from "@working-theory/ui/primitives";
27
+ import type { Metadata } from "next";
28
+ import { notFound } from "next/navigation";
29
+ import { getTranslations } from "next-intl/server";
30
+ import type { ReactElement, ReactNode } from "react";
31
+
32
+ import { acceptInvitation, readInvitation } from "./actions";
33
+ import { isInvitationId } from "./invitation-id";
34
+
35
+ interface Props {
36
+ params: Promise<{ locale: string; invitationId: string }>;
37
+ searchParams: Promise<{ joined?: string | string[]; error?: string | string[] }>;
38
+ }
39
+
40
+ export async function generateMetadata({ params }: Props): Promise<Metadata> {
41
+ const { locale } = await params;
42
+ const t = await getTranslations({ locale, namespace: "account" });
43
+ return { title: t("invitation.accept"), robots: { index: false, follow: false } };
44
+ }
45
+
46
+ /** `?error=` → its line's key; an unknown value is the generic failure. */
47
+ const ERROR_KEYS = {
48
+ invitation_for_another_address: "invitation.otherAddress",
49
+ invitation_not_pending: "invitation.notPending",
50
+ invitation_expired: "invitation.expired",
51
+ invitation_void: "invitation.void",
52
+ already_member: "invitation.alreadyMember",
53
+ } as const;
54
+
55
+ function errorKeyFor(
56
+ error: string | string[] | undefined,
57
+ ): (typeof ERROR_KEYS)[keyof typeof ERROR_KEYS] | "invitation.failed" | null {
58
+ if (typeof error !== "string") return null;
59
+ return Object.hasOwn(ERROR_KEYS, error)
60
+ ? ERROR_KEYS[error as keyof typeof ERROR_KEYS]
61
+ : "invitation.failed";
62
+ }
63
+
64
+ function Frame({ children }: { children: ReactNode }): ReactElement {
65
+ return (
66
+ <Container className="py-section">
67
+ <div className="flex max-w-prose flex-col gap-4" data-testid="account-invitation">
68
+ {children}
69
+ </div>
70
+ </Container>
71
+ );
72
+ }
73
+
74
+ export default async function AccountInvitationPage({
75
+ params,
76
+ searchParams,
77
+ }: Props): Promise<ReactElement> {
78
+ const { locale, invitationId } = await params;
79
+ const { joined, error } = await searchParams;
80
+ if (!isInvitationId(invitationId)) notFound();
81
+ const t = await getTranslations({ locale, namespace: "account" });
82
+ const read = await readInvitation(invitationId);
83
+
84
+ if (read.kind === "not_found") notFound();
85
+ if (read.kind === "other_address" || read.kind === "failed") {
86
+ return (
87
+ <Frame>
88
+ <InlineMessage
89
+ variant="error"
90
+ role="alert"
91
+ data-testid={read.kind === "other_address" ? "account-invitation-other-address" : "account-invitation-failed"}
92
+ >
93
+ {t(read.kind === "other_address" ? "invitation.otherAddress" : "invitation.failed")}
94
+ </InlineMessage>
95
+ </Frame>
96
+ );
97
+ }
98
+
99
+ const { invitation } = read;
100
+ const organization = invitation.organizationName;
101
+
102
+ if (invitation.status === "accepted" && joined === "1") {
103
+ return (
104
+ <Frame>
105
+ <div data-testid="account-invitation-joined">
106
+ <Heading level={1} visual={3}>
107
+ {t("invitation.joined", { organization })}
108
+ </Heading>
109
+ </div>
110
+ <Text as="p" variant="body" tone="muted">
111
+ {t("invitation.joinedLead")}
112
+ </Text>
113
+ </Frame>
114
+ );
115
+ }
116
+
117
+ const expired =
118
+ invitation.expiresAt !== null && Date.parse(invitation.expiresAt) <= Date.now();
119
+ if (invitation.status !== "pending" || expired) {
120
+ return (
121
+ <Frame>
122
+ <InlineMessage variant="default" role="status" data-testid="account-invitation-closed">
123
+ {t(expired && invitation.status === "pending" ? "invitation.expired" : "invitation.notPending")}
124
+ </InlineMessage>
125
+ </Frame>
126
+ );
127
+ }
128
+
129
+ const role = t(`invitation.roles.${invitation.role}`);
130
+ const errorKey = errorKeyFor(error);
131
+
132
+ return (
133
+ <Frame>
134
+ <Heading level={1} visual={3}>
135
+ {t("invitation.title", { organization })}
136
+ </Heading>
137
+ <Text as="p" variant="body" data-testid="account-invitation-lead">
138
+ {invitation.inviterName
139
+ ? t("invitation.lead", { inviter: invitation.inviterName, organization, role })
140
+ : t("invitation.leadNoInviter", { organization, role })}
141
+ </Text>
142
+ {errorKey ? (
143
+ <InlineMessage variant="error" role="alert" data-testid="account-invitation-error">
144
+ {t(errorKey)}
145
+ </InlineMessage>
146
+ ) : null}
147
+ <form action={acceptInvitation.bind(null, invitationId, locale)} data-testid="account-invitation-form">
148
+ <Button type="submit" size="big" data-testid="account-invitation-accept">
149
+ {t("invitation.accept")}
150
+ </Button>
151
+ </form>
152
+ </Frame>
153
+ );
154
+ }
@@ -5,8 +5,8 @@
5
5
  * RSC. Every `/account` route but the four Settings tabs renders inside
6
6
  * `SignedInShell` (through the client `AccountFrame`; the tabs draw their own
7
7
  * standalone settings frame, #8430): the site's logo as the rail's top tile, linking
8
- * home; the rail's rows — Inbox, a Library group holding Artifacts, then
9
- * Settings (#8231 D1); a footer of the avatar and ? alone;
8
+ * home; the rail's rows — Inbox, a Library group holding Artifacts and
9
+ * Appointments (#8231 D1, #11154); a footer of the avatar and ? alone;
10
10
  * the card avatar menu (name, then Settings and Log out); the ? help menu
11
11
  * (Contact support, and Help center when `AILK_HELP_CENTER_URL` is set);
12
12
  * and below `md` a tab bar reading avatar · Inbox · For you · Help (#7469).
@@ -18,8 +18,10 @@
18
18
  * the Inbox's phone For you tab); with no items there is no aside.
19
19
  *
20
20
  * #8465 — `SIGN_OUT_ENDPOINT` (set only on a spoke that signs in through its
21
- * hub) and `SIGN_IN_PATH` ride down as props; the client frame cannot import
22
- * the generated seam, and the signed-in Nav reads it the same way.
21
+ * hub) rides down as a prop; the client frame cannot import the generated
22
+ * seam. After that sign-out the frame lands on the site's home (#11095 D4):
23
+ * the spoke's `/account` would sign the person straight back in while their
24
+ * hub session lives.
23
25
  *
24
26
  * The `(authed)` layout above owns the signed-out gate, so a missing session
25
27
  * here is a race (it expired between the two layouts): the page renders
@@ -41,7 +43,7 @@ import { getTranslations } from "next-intl/server";
41
43
  import type { ReactElement, ReactNode } from "react";
42
44
 
43
45
  import { siteLogo } from "../../../../lib/site-logo";
44
- import { SIGN_IN_PATH, SIGN_OUT_ENDPOINT } from "../../../../lib/topology.generated";
46
+ import { SIGN_OUT_ENDPOINT } from "../../../../lib/topology.generated";
45
47
 
46
48
  import { accountSession, loadForYou } from "./account-data";
47
49
  import { AccountFrame } from "./account-frame";
@@ -76,7 +78,7 @@ export default async function AccountLayout({
76
78
  const signOutProps = SIGN_OUT_ENDPOINT
77
79
  ? {
78
80
  signOutEndpoint: SIGN_OUT_ENDPOINT,
79
- signInHref: localeHref(locale, SIGN_IN_PATH ?? "/"),
81
+ signInHref: localeHref(locale, "/"),
80
82
  }
81
83
  : {};
82
84
 
@@ -128,6 +130,7 @@ export default async function AccountLayout({
128
130
  settings: t("frame.settings"),
129
131
  library: t("frame.library"),
130
132
  artifacts: t("frame.artifacts"),
133
+ appointments: t("frame.appointments"),
131
134
  signOutFailed: t("frame.signOutFailed"),
132
135
  signOut: t("frame.signOut"),
133
136
  help: t("frame.help"),
@@ -7,8 +7,10 @@
7
7
  *
8
8
  * Its rows are the contributed New actions the Inbox page found offered
9
9
  * (`accountNewActions`, each already gated by its own member read). A row is
10
- * a menu item, never a link: it opens that action's popup in one dialog over
11
- * the Inbox. With no action offered there is no menu at all.
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.
12
14
  *
13
15
  * Two triggers share the dialog: the desktop New in the page's header row
14
16
  * (`md` up), and a compact + the frame's phone top bar holds. The frame hands
@@ -18,9 +20,9 @@
18
20
  *
19
21
  * A popup body talks back through `useNewMenuPopup()`: `close(true)` after a
20
22
  * successful write closes the dialog and refreshes the Inbox, `open(id)`
21
- * switches to another offered action. The two popups that read on open share
23
+ * switches to another offered action. A popup that reads on open uses
22
24
  * `useOpenRead` and `NewPopupStatus`, so loading, a failed read and its retry
23
- * look the same in both (D5).
25
+ * look the same in every popup (D5).
24
26
  */
25
27
 
26
28
  import {
@@ -54,11 +56,13 @@ import { createPortal } from "react-dom";
54
56
 
55
57
  import type { NewActionErrorCode } from "./new-actions";
56
58
 
57
- /** One offered action, its label already translated. */
59
+ /** One offered action, its label already translated: a popup, or a page to navigate to (#11154). */
58
60
  export interface NewMenuAction {
59
61
  id: string;
60
62
  label: string;
61
- popup: ReactNode;
63
+ popup?: ReactNode;
64
+ /** The localized path the row navigates to; such a row has no popup. */
65
+ href?: string;
62
66
  }
63
67
 
64
68
  export interface NewMenuLabels {
@@ -125,11 +129,13 @@ function ActionMenu({
125
129
  actions,
126
130
  label,
127
131
  onPick,
132
+ onNavigate,
128
133
  }: {
129
134
  compact: boolean;
130
135
  actions: readonly NewMenuAction[];
131
136
  label: string;
132
137
  onPick: (id: string, trigger: HTMLElement | null) => void;
138
+ onNavigate: (href: string) => void;
133
139
  }): ReactElement {
134
140
  const triggerRef = useRef<HTMLButtonElement>(null);
135
141
  // A pick hands focus to the dialog, so the closing menu must not take it back.
@@ -175,9 +181,15 @@ function ActionMenu({
175
181
  <DropdownMenuItem
176
182
  key={action.id}
177
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
+ }
178
189
  picked.current = true;
179
190
  onPick(action.id, triggerRef.current);
180
191
  }}
192
+ {...(action.href !== undefined ? { "data-href": action.href } : {})}
181
193
  data-testid={`account-new-menu-item-${action.id}`}
182
194
  >
183
195
  {action.label}
@@ -222,13 +234,26 @@ export function NewMenu({
222
234
  returnFocus.current = trigger;
223
235
  setOpenId(id);
224
236
  };
237
+ const onNavigate = (href: string): void => router.push(href);
225
238
 
226
239
  return (
227
240
  <>
228
- <ActionMenu compact={false} actions={actions} label={labels.trigger} onPick={onPick} />
241
+ <ActionMenu
242
+ compact={false}
243
+ actions={actions}
244
+ label={labels.trigger}
245
+ onPick={onPick}
246
+ onNavigate={onNavigate}
247
+ />
229
248
  {slot
230
249
  ? createPortal(
231
- <ActionMenu compact actions={actions} label={labels.trigger} onPick={onPick} />,
250
+ <ActionMenu
251
+ compact
252
+ actions={actions}
253
+ label={labels.trigger}
254
+ onPick={onPick}
255
+ onNavigate={onNavigate}
256
+ />,
232
257
  slot,
233
258
  )
234
259
  : null}
@@ -20,7 +20,11 @@
20
20
  * `ctx`, its init, its user or `t` itself — so no credential or email reaches
21
21
  * the client payload (SEC-8233-1). `popups` is keyed on the config's own id
22
22
  * union, so a read added there without a popup here is a type error, never a
23
- * menu row that opens nothing.
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.
24
28
  */
25
29
 
26
30
  import type {
@@ -30,16 +34,26 @@ import type {
30
34
  } from "@working-theory/templates/account";
31
35
  import type { ReactNode } from "react";
32
36
 
33
- import {
34
- accountNewActions,
35
- type AccountNewActionId,
36
- } from "../../../../lib/account-config";
37
+ import { accountNewActions } from "../../../../lib/account-config";
37
38
 
38
39
  import { RequestQuote } from "./components/request-quote";
39
- import { ScheduleService } from "./components/schedule-service";
40
- import { SendMessage } from "./components/send-message";
40
+ import type { NewActionErrorCode } from "./new-actions";
41
41
  import type { NewPopupLabels } from "./new-menu";
42
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
+
43
57
  /** The strings every popup shares — plain strings, so nothing else crosses to the client. */
44
58
  function popupLabels(t: AccountTranslate): NewPopupLabels {
45
59
  return {
@@ -48,60 +62,25 @@ function popupLabels(t: AccountTranslate): NewPopupLabels {
48
62
  retry: t("new.retry"),
49
63
  submitting: t("new.submitting"),
50
64
  optional: t("new.optional"),
51
- errors: {
52
- link_not_https: t("new.errors.linkNotHttps"),
53
- answers_invalid: t("new.errors.answersInvalid"),
54
- request_form_off: t("new.errors.requestFormOff"),
55
- meeting_type_not_offered: t("new.errors.meetingTypeNotOffered"),
56
- slot_unavailable: t("new.errors.slotUnavailable"),
57
- too_many_requests: t("new.errors.tooManyRequests"),
58
- invalid_input: t("new.errors.invalidInput"),
59
- failed: t("new.errors.failed"),
60
- },
65
+ errors: newActionErrorLabels(t),
61
66
  };
62
67
  }
63
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
+
64
72
  /** The popup each action opens, keyed on the config's ids (D6–D8). */
65
73
  const popups = {
66
- "schedule-service": ({ locale, t }) => (
67
- <ScheduleService
68
- locale={locale}
69
- labels={{
70
- ...popupLabels(t),
71
- service: t("new.schedule.service"),
72
- // The popup fills each type's own minutes into the literal placeholder.
73
- duration: t("new.schedule.duration", { minutes: "{minutes}" }),
74
- time: t("new.schedule.time"),
75
- notes: t("new.schedule.notes"),
76
- submit: t("new.schedule.submit"),
77
- none: t("new.schedule.none"),
78
- suggest: t("new.schedule.suggest"),
79
- noSlots: t("new.schedule.noSlots"),
80
- }}
81
- />
82
- ),
83
74
  "request-quote": ({ locale, t }) => (
84
- <RequestQuote locale={locale} labels={{ ...popupLabels(t), submit: t("new.quote.submit") }} />
85
- ),
86
- "send-message": ({ locale, t }) => (
87
- <SendMessage
75
+ <RequestQuote
88
76
  locale={locale}
89
- labels={{
90
- ...popupLabels(t),
91
- subject: t("new.message.subject"),
92
- body: t("new.message.body"),
93
- link: t("new.message.link"),
94
- linkHelp: t("new.message.linkHelp"),
95
- submit: t("new.message.submit"),
96
- }}
77
+ labels={{ ...popupLabels(t), submit: t("new.quote.submit"), pickDate: t("new.quote.pickDate") }}
97
78
  />
98
79
  ),
99
- } satisfies Record<AccountNewActionId, (ctx: AccountContext) => ReactNode>;
80
+ } satisfies Record<AccountNewPopupId, (ctx: AccountContext) => ReactNode>;
100
81
 
101
- /** The New actions in menu order (D2), each with its popup — what the Inbox page offers. */
82
+ /** The New actions in menu order (D2), each with its popup or its page — what the Inbox page offers. */
102
83
  export const newActions: readonly AccountNewAction[] = accountNewActions.map(
103
- (read) => ({
104
- ...read,
105
- renderPopup: popups[read.id],
106
- }),
84
+ (read): AccountNewAction =>
85
+ "href" in read ? read : { ...read, renderPopup: popups[read.id] },
107
86
  );
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * /[locale]/account/notifications — User settings › Notifications (#8339
3
- * D8; #8438 D15 — what we send you).
3
+ * D8; #8438 D15 — what we send you; #11163 — Ploy's three-row shape).
4
4
  *
5
5
  * RSC, outside the account layout's SignedInShell (#8430), in the member's
6
6
  * settings frame (D7) — standalone, the Admin's shape. Always renders
@@ -10,6 +10,15 @@
10
10
  * `effective` default (no row ⇒ on for a preference, off for a consent).
11
11
  * With none declared, one `account-notifications-empty` line.
12
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
+ *
13
22
  * The cookie-settings link moved to Privacy (#8438 D14, C6) — this tab no
14
23
  * longer renders it.
15
24
  */
@@ -21,6 +30,15 @@ import {
21
30
  ConsentSwitchList,
22
31
  type ConsentSwitchRow,
23
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";
24
42
  import type { Metadata } from "next";
25
43
  import { getTranslations } from "next-intl/server";
26
44
  import type { ReactElement } from "react";
@@ -29,6 +47,19 @@ import { accountSession } from "../account-data";
29
47
  import { setConsentAction } from "../privacy/actions";
30
48
  import { memberSettingsFrame, type Translate } from "../settings-frame";
31
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
+ }
32
63
 
33
64
  interface Props {
34
65
  params: Promise<{ locale: string }>;
@@ -57,9 +88,15 @@ export default async function AccountNotificationsPage({ params }: Props): Promi
57
88
  .filter((purpose) => purpose.area === "communications")
58
89
  .map((purpose) => ({
59
90
  id: purpose.id,
60
- label: purpose.statement,
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 }),
61
99
  granted: purpose.effective,
62
- ...(purpose.description ? { description: purpose.description } : {}),
63
100
  ...(purpose.state
64
101
  ? {
65
102
  dateLine: purpose.state.granted
@@ -90,6 +127,7 @@ export default async function AccountNotificationsPage({ params }: Props): Promi
90
127
  rows={rows}
91
128
  onChange={setConsentAction}
92
129
  emptyLine={t("settings.notifications.empty")}
130
+ footLine={t("settings.notifications.alwaysSent")}
93
131
  testIdPrefix="account-notifications"
94
132
  />
95
133
  )}
@@ -98,6 +136,8 @@ export default async function AccountNotificationsPage({ params }: Props): Promi
98
136
  );
99
137
  }
100
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.
101
141
  function formatDate(iso: string, locale: string): string {
102
- return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(new Date(iso));
142
+ return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
103
143
  }