feat: marketing email consent UI (post-login prompt + account settings) (#4554)

Resolves #4029

## Description:

Client-side marketing-email consent capture — the client half of #4029.
It consumes the already-merged API (`GET /users/@me` marketing-consent
state + `POST /marketing/consent`); **no backend changes**.

**Three surfaces:**

- **Post-login prompt** — a small, non-blocking toast docked top-right,
shown once after login when the player's consent is undecided
(`no_response`) and a verified email is on file. Yes / No thanks /
dismiss all record a decision, and it never re-nags.
- **Account → "Account Settings" tab** — a persistent on/off toggle to
change or withdraw consent at any time (the GDPR change/withdraw path).
- **No-email state** — when the account has no verified email, the tab
offers to bind one (magic link to a plain email — the backend's
`new-association` path — or link Google) so the player can subscribe.

Styling matches the game's existing panels (`bg-surface`,
`border-white/10`, `shadow-[var(--shadow-malibu-blue)]`, malibu-blue
accent), reusing `o-button` and the account modal's existing email
field/handlers.

**Changes:**

- New `<marketing-consent-toast>`
(`src/client/MarketingConsentToast.ts`), mounted in `index.html`,
registered in `Main.ts`.
- `AccountModal.ts`: new "Account Settings" tab (toggle + bind-email
state), optimistic with revert-on-failure.
- `Api.ts`: `setMarketingConsent()` → `POST /marketing/consent`,
invalidates cached `/users/@me`.
- `ApiSchemas.ts`: optional `player.marketingConsent { consented,
hasEmail }` on `UserMeResponse`.
- `en.json`: `marketing_consent.*` + `account_modal.marketing_*` /
`tab_settings`.

## Please complete the following:

- [x] I have added screenshots for all UI updates <!-- attaching in a
follow-up comment -->
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory

## Please put your Discord username so you can be contacted if a bug or
regression is found:

Iamlewis

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
iamlewis
2026-07-10 10:13:37 +00:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 921892e941
commit 8e5f27949f
8 changed files with 494 additions and 25 deletions
+12
View File
@@ -30,6 +30,9 @@
"linked_to_google_email": "Linked to Google ({email})",
"log_out": "Log Out",
"manage_subscription": "Manage",
"marketing_desc": "Occasional news, events, and game updates. Unsubscribe anytime.",
"marketing_no_email": "Link an email to your account to subscribe to updates.",
"marketing_title": "Email updates",
"no_games": "No games played yet.",
"no_stats": "No stats available yet. Play some games to start tracking.",
"not_found": "Not Found",
@@ -55,6 +58,7 @@
"tab_account": "Account",
"tab_friends": "Friends",
"tab_games": "Games",
"tab_settings": "Settings",
"tab_stats": "Stats",
"title": "Account",
"your_subscription": "Your Subscription"
@@ -1042,6 +1046,14 @@
"search_results": "Search Results",
"unfavorite": "Remove from favourites"
},
"marketing_consent": {
"body": "News and updates by email. Change it anytime in your account.",
"dismiss": "Dismiss",
"error": "Couldn't save that. Please try again.",
"no": "No thanks",
"title": "Keep up with OpenFront?",
"yes": "Yes please"
},
"matchmaking_button": {
"description": "(ALPHA)",
"login_required": "Login to play ranked!",