Add Aniimo guides and link game cards to toolbox checklists
Some checks failed
Deploy Sokko G / deploy (push) Failing after 3s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 3s
This commit is contained in:
parent
f0797ccf14
commit
13434f72f6
278 changed files with 10025 additions and 57 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Rôle : charge le contenu éditorial et les données publiques nécessaires à l'application.
|
||||
import { useEffect, useState } from "react";
|
||||
import { INITIAL_DIABLO4_STATE, INITIAL_MHWILDS_STATE, loadDiablo4Data, loadMhwildsData } from "../features/games/loaders.js";
|
||||
import { INITIAL_ANIIMO_STATE, loadAniimoData, INITIAL_DIABLO4_STATE, INITIAL_MHWILDS_STATE, loadDiablo4Data, loadMhwildsData } from "../features/games/loaders.js";
|
||||
|
||||
function useGameData(active, initialState, load) {
|
||||
const [requested, setRequested] = useState(active);
|
||||
|
|
@ -30,6 +30,7 @@ export function useAppData(route) {
|
|||
const [games, setGames] = useState([]);
|
||||
const [gamesError, setGamesError] = useState("");
|
||||
const mhwilds = useGameData(route.startsWith("/games/mhwilds"), INITIAL_MHWILDS_STATE, loadMhwildsData);
|
||||
const aniimo = useGameData(route.startsWith("/games/aniimo"), INITIAL_ANIIMO_STATE, loadAniimoData);
|
||||
const diablo4 = useGameData(route.startsWith("/games/diablo4"), INITIAL_DIABLO4_STATE, loadDiablo4Data);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -64,6 +65,7 @@ export function useAppData(route) {
|
|||
games,
|
||||
gamesError,
|
||||
mhwilds,
|
||||
diablo4
|
||||
diablo4,
|
||||
aniimo
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// Rôle : gère l'état des filtres actifs pour les pages de jeu.
|
||||
import { useState } from "react";
|
||||
import { createAniimoFilters } from "../features/games/aniimo/utils.js";
|
||||
|
||||
export function useGameFilters() {
|
||||
return useState({
|
||||
aniimo: createAniimoFilters(),
|
||||
monsters: { name: "", weaknesses: [], logic: "and" },
|
||||
endemic: { name: "", locations: [], logic: "and" },
|
||||
diablo4: { name: "", categories: [], logic: "and" }
|
||||
|
|
|
|||
34
website/src/hooks/useGuideChecklistSession.js
Normal file
34
website/src/hooks/useGuideChecklistSession.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// Rôle : conserve les liaisons guide/checklist pendant la session et retire les références supprimées.
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { GUIDE_CHECKLIST_SESSION_KEY, validGuideAssociations } from "../features/games/guideChecklist.js";
|
||||
|
||||
function readSession() {
|
||||
try {
|
||||
const value = JSON.parse(sessionStorage.getItem(GUIDE_CHECKLIST_SESSION_KEY) || "{}");
|
||||
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
||||
} catch { return {}; }
|
||||
}
|
||||
|
||||
export function useGuideChecklistSession({ toolboxes, links, ready }) {
|
||||
const [associations, setAssociations] = useState(readSession);
|
||||
const valid = useMemo(() => ready ? validGuideAssociations(associations, toolboxes, links) : associations, [associations, toolboxes, links, ready]);
|
||||
if (ready && Object.keys(valid).length !== Object.keys(associations).length) setAssociations(valid);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
try {
|
||||
if (Object.keys(valid).length) sessionStorage.setItem(GUIDE_CHECKLIST_SESSION_KEY, JSON.stringify(valid));
|
||||
else sessionStorage.removeItem(GUIDE_CHECKLIST_SESSION_KEY);
|
||||
} catch { /* La session reste disponible en mémoire si le navigateur refuse le stockage. */ }
|
||||
}, [ready, valid]);
|
||||
|
||||
function setAssociation(guideId, association) {
|
||||
setAssociations((current) => {
|
||||
const next = { ...current };
|
||||
if (association) next[guideId] = association;
|
||||
else delete next[guideId];
|
||||
return next;
|
||||
});
|
||||
}
|
||||
return { associations: valid, setAssociation };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue