/** * @file Nomme les pages qui ouvrent le tiroir de toolbox : la page d'un jeu (sa toolbox liée), ou Sokko TCG * dans toutes ses sections, où le joueur choisit n'importe laquelle de ses toolboxes dans une liste, * sans liaison. */ export const CARDS_TOOLBOX_TARGET_ID = "sokko-tcg"; /** Le même tiroir reste ouvert d'une section de Sokko TCG à l'autre (Guilde, Expéditions, Collection…), administration comprise. */ export function getRouteToolboxTargetId(route) { const gameMatch = route.match(/^\/games\/([^/]+)/); // `/games/sokko-tcg` n'est pas une page de jeu : elle n'ouvre pas le tiroir de Sokko TCG. if (gameMatch) return gameMatch[1] === CARDS_TOOLBOX_TARGET_ID ? "" : gameMatch[1]; return route === "/cards" || route.startsWith("/cards/") ? CARDS_TOOLBOX_TARGET_ID : ""; } /** Toolbox affichée par le tiroir : celle liée au jeu, ou celle choisie dans Sokko TCG tant qu'elle existe encore. */ export function getDrawerToolboxId(targetId, links, cardsToolboxId, toolboxes) { if (!targetId) return ""; if (targetId !== CARDS_TOOLBOX_TARGET_ID) return links[targetId] || ""; return cardsToolboxId && toolboxes.some((toolbox) => toolbox.id === cardsToolboxId) ? cardsToolboxId : ""; }