Let Cards players delete their account and read a privacy notice
Add a Compte section with a privacy notice and a confirmed deletion that anonymises the player row, erases their possessions and cancels open trades. The public contact comes from CARDS_PRIVACY_CONTACT, which production now requires before enabling the game. The admin E2E no longer relies on a pull from the previous test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
155187d01f
commit
e60fbd4e9b
16 changed files with 319 additions and 10 deletions
|
|
@ -3,17 +3,19 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|||
import { navigate } from "../../router/hashRouter.js";
|
||||
import { AdminPanel } from "./admin/AdminPanel.jsx";
|
||||
import { clearCardsCache, readLatestCardsCache, writeCardsCache } from "./cardCache.js";
|
||||
import { devLogin, loadCardsSession, loadCardsState, logoutCards } from "./cardsApi.js";
|
||||
import { AccountPanel } from "./AccountPanel.jsx";
|
||||
import { deleteCardsAccount, devLogin, loadCardsSession, loadCardsState, logoutCards } from "./cardsApi.js";
|
||||
import { CardsAccount, CardsDashboardLayout } from "./CardsDashboard.jsx";
|
||||
import { CardsHomePanel } from "./CardsHomePanel.jsx";
|
||||
import { CollectionPanel } from "./CollectionPanel.jsx";
|
||||
import { HistoryPanel } from "./HistoryPanel.jsx";
|
||||
import { PackPanel } from "./PackPanel.jsx";
|
||||
import { PrivacyNotice } from "./PrivacyNotice.jsx";
|
||||
import { ShopPanel } from "./ShopPanel.jsx";
|
||||
import { TransfersPanel } from "./TransfersPanel.jsx";
|
||||
|
||||
// Le jeu, puis l'économie et les échanges, puis le journal : mêmes groupes séparés par un filet que l'administration.
|
||||
const PLAYER_NAVIGATION = [["home", "packs", "collection"], ["shop", "transfers"], ["history"]];
|
||||
const PLAYER_NAVIGATION = [["home", "packs", "collection"], ["shop", "transfers"], ["history", "account"]];
|
||||
const PLAYER_SECTIONS = new Set(PLAYER_NAVIGATION.flat());
|
||||
// Ancienne adresse conservée pour les favoris : le recyclage vit désormais dans la Collection.
|
||||
const PLAYER_SECTION_ALIASES = { recycling: "collection" };
|
||||
|
|
@ -42,6 +44,7 @@ export function CardsPage({ siteContent, cardsConfig, playerSection = "", adminM
|
|||
const [error, setError] = useState("");
|
||||
const [authFailure] = useState(readDiscordAuthFailure);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [accountDeleted, setAccountDeleted] = useState(false);
|
||||
const resolvedSection = PLAYER_SECTION_ALIASES[playerSection] || playerSection;
|
||||
const section = PLAYER_SECTIONS.has(resolvedSection) ? resolvedSection : "home";
|
||||
const [transferDraft, setTransferDraft] = useState(null);
|
||||
|
|
@ -180,9 +183,24 @@ export function CardsPage({ siteContent, cardsConfig, playerSection = "", adminM
|
|||
{!cardsConfig.discordConfigured && <p className="nds-inline-notice" data-variant="warning" role="status">{content.discordUnavailable}</p>}
|
||||
{authFailure && <p className="nds-inline-notice" data-variant="danger" role="alert">{content.discordErrors[authFailure] || content.discordErrors.failed}</p>}
|
||||
{error && <p className="nds-inline-notice" data-variant="danger" role="alert">{error}</p>}
|
||||
{accountDeleted && <p className="nds-inline-notice" data-variant="success" role="status">{content.account.deleted}</p>}
|
||||
<details className="nebula-privacy-details">
|
||||
<summary>{content.privacy.title}</summary>
|
||||
<PrivacyNotice content={content.privacy} contact={cardsConfig.privacyContact} />
|
||||
</details>
|
||||
</div>
|
||||
</section>;
|
||||
|
||||
async function deleteAccount() {
|
||||
const result = await runMutation(() => deleteCardsAccount());
|
||||
if (!result?.ok) return;
|
||||
await clearCardsCache().catch(() => {});
|
||||
setState(null);
|
||||
setAccountDeleted(true);
|
||||
setStatus("anonymous");
|
||||
navigate("/cards");
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await logoutCards();
|
||||
await clearCardsCache().catch(() => {});
|
||||
|
|
@ -234,6 +252,7 @@ export function CardsPage({ siteContent, cardsConfig, playerSection = "", adminM
|
|||
{section === "shop" && <ShopPanel {...panelProps} content={content.shop} onOpenPacks={openPacks} />}
|
||||
{section === "transfers" && <TransfersPanel {...panelProps} content={content.transfers} draft={transferDraft} onDraftUsed={clearTransferDraft} />}
|
||||
{section === "history" && <HistoryPanel catalog={catalog} state={state} content={content.history} />}
|
||||
{section === "account" && <AccountPanel state={state} busy={busy || offline} content={content.account} privacy={content.privacy} privacyContact={cardsConfig.privacyContact} onDelete={deleteAccount} />}
|
||||
</CardsDashboardLayout>
|
||||
</div>}
|
||||
</div>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue