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
39
website/src/features/cards/AccountPanel.jsx
Normal file
39
website/src/features/cards/AccountPanel.jsx
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Rôle : présente au joueur les données liées à son compte, la notice de confidentialité et la suppression du compte.
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../components/ToolboxModals.jsx";
|
||||
import { PrivacyNotice } from "./PrivacyNotice.jsx";
|
||||
|
||||
export function AccountPanel({ state, busy, content, privacy, privacyContact, onDelete }) {
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
const cards = state.collection.reduce((total, entry) => total + entry.quantity, 0);
|
||||
return <div className="nebula-account">
|
||||
<div className="nds-section-heading nebula-section-heading"><div><p className="eyebrow">{content.eyebrow}</p><h2>{content.title}</h2><p>{content.description}</p></div></div>
|
||||
<section className="nds-panel nebula-account-summary" aria-labelledby="nebula-account-summary-title">
|
||||
<h3 id="nebula-account-summary-title">{content.summaryTitle}</h3>
|
||||
<dl>
|
||||
<div><dt>{content.summaryName}</dt><dd>{state.player.displayName}</dd></div>
|
||||
<div><dt>{content.summaryCards}</dt><dd>{cards.toLocaleString("fr-FR")}</dd></div>
|
||||
<div><dt>{content.summaryOpenings}</dt><dd>{state.stats.openingsCount.toLocaleString("fr-FR")}</dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
<section className="nds-panel" aria-labelledby="nebula-account-privacy-title">
|
||||
<h3 id="nebula-account-privacy-title">{privacy.title}</h3>
|
||||
<PrivacyNotice content={privacy} contact={privacyContact} />
|
||||
</section>
|
||||
<section className="nds-panel nebula-account-delete" aria-labelledby="nebula-account-delete-title">
|
||||
<h3 id="nebula-account-delete-title">{content.deleteTitle}</h3>
|
||||
<p>{content.deleteText}</p>
|
||||
<button className="nds-button" data-size="sm" data-variant="danger" type="button" disabled={busy} onClick={() => setConfirming(true)}>{content.deleteButton}</button>
|
||||
</section>
|
||||
{confirming && <ConfirmModal
|
||||
title={content.confirmTitle}
|
||||
message={content.confirmMessage}
|
||||
confirmLabel={content.confirmLabel}
|
||||
danger
|
||||
onClose={(confirmed) => {
|
||||
setConfirming(false);
|
||||
if (confirmed) void onDelete();
|
||||
}}
|
||||
/>}
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -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>;
|
||||
|
|
|
|||
13
website/src/features/cards/PrivacyNotice.jsx
Normal file
13
website/src/features/cards/PrivacyNotice.jsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Rôle : présente la notice de confidentialité de Sokko TCG et le contact configuré sur le serveur.
|
||||
const SECTIONS = ["collected", "purpose", "visibility", "retention", "rights"];
|
||||
|
||||
export function PrivacyNotice({ content, contact }) {
|
||||
return <div className="nebula-privacy-notice">
|
||||
<p>{content.intro}</p>
|
||||
{SECTIONS.map((section) => <section key={section}>
|
||||
<h4>{content[`${section}Title`]}</h4>
|
||||
<p>{content[section]}</p>
|
||||
</section>)}
|
||||
<p className="nebula-privacy-contact"><strong>{content.contactLabel}</strong> {contact ? <a href={`mailto:${contact}`}>{contact}</a> : content.contactMissing}</p>
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -14,7 +14,8 @@ const EVENT_LABELS = {
|
|||
drop_rates_updated: "Taux de tirage modifiés",
|
||||
campaign_created: "Campagne créée",
|
||||
campaign_revoked: "Campagne révoquée",
|
||||
campaign_extended: "Campagne prolongée"
|
||||
campaign_extended: "Campagne prolongée",
|
||||
account_deleted: "Compte joueur supprimé"
|
||||
};
|
||||
|
||||
const collectionName = (entry, catalog) => catalog.collections.find((item) => item.id === entry.entityId)?.name || entry.entityId;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ export async function logoutCards() {
|
|||
return result;
|
||||
}
|
||||
|
||||
export async function deleteCardsAccount() {
|
||||
const result = await request("/account", { method: "DELETE" });
|
||||
csrfToken = "";
|
||||
return result;
|
||||
}
|
||||
|
||||
// `purchased` : utilise une ouverture achetée en boutique au lieu de la réserve rechargeable.
|
||||
export function openPack(collectionId, { purchased = false } = {}) {
|
||||
const requestKey = crypto.randomUUID();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue