sokko-g/website/src/features/cards/useCardsConfig.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

22 lines
969 B
JavaScript

/**
* @file Détecte la disponibilité de Sokko TCG et partage son catalogue public.
*/
import { useCallback, useEffect, useState } from "react";
import { loadCardsConfig } from "./cardsApi.js";
export function useCardsConfig() {
const [config, setConfig] = useState({ loading: true, enabled: false, devAuth: false, catalog: null, error: "" });
useEffect(() => {
let active = true;
loadCardsConfig()
.then((value) => { if (active) setConfig({ loading: false, error: "", ...value }); })
.catch((error) => { if (active) setConfig({ loading: false, enabled: false, devAuth: false, catalog: null, error: error.message }); });
return () => { active = false; };
}, []);
// Remplace le catalogue publié après une modification admin, sans recharger la configuration.
const replaceCatalog = useCallback((catalog) => {
if (catalog) setConfig((current) => ({ ...current, catalog }));
}, []);
return { ...config, replaceCatalog };
}