sokko-g/website/src/features/toolboxes/useCardsToolboxChoice.js
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 09:42:13 +01:00

33 lines
1,023 B
JavaScript

/**
* @file Retient, sur cet appareil, la toolbox choisie dans le tiroir de Sokko TCG, pour la rouvrir
* directement à la visite suivante.
*
* Une préférence d'affichage, pas une donnée de toolbox : elle n'entre ni dans les liaisons ni dans les
* exports.
*/
import { useCallback, useState } from "react";
const CARDS_TOOLBOX_STORAGE_KEY = "sokkog:cards-toolbox";
function readChoice() {
try {
return globalThis.localStorage?.getItem(CARDS_TOOLBOX_STORAGE_KEY) || "";
} catch {
return "";
}
}
export function useCardsToolboxChoice() {
const [toolboxId, setToolboxId] = useState(readChoice);
const choose = useCallback((nextId) => {
setToolboxId(nextId || "");
try {
if (nextId) globalThis.localStorage?.setItem(CARDS_TOOLBOX_STORAGE_KEY, nextId);
else globalThis.localStorage?.removeItem(CARDS_TOOLBOX_STORAGE_KEY);
} catch {
// Stockage refusé (navigation privée, quota) : le choix vaut pour la session.
}
}, []);
return [toolboxId, choose];
}