diff --git a/src/components/Ressources/Ressource.tsx b/src/components/Ressources/Ressource.tsx index 69230d20f..dd6deb452 100644 --- a/src/components/Ressources/Ressource.tsx +++ b/src/components/Ressources/Ressource.tsx @@ -39,6 +39,13 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }; }, [router, ressourceKey]); + const selected = { + issues: Object.keys(issues).includes(ressourceKey), + understandings: Object.keys(understandings).includes(ressourceKey), + growths: Object.keys(growths).includes(ressourceKey), + coldNetworks: Object.keys(coldNetworks).includes(ressourceKey), + }; + return ( <>
{ items={[ { text: 'Les enjeux de la transition énergétique avec les réseaux de chaleur', - isActive: Object.keys(issues).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.issues, + expandedByDefault: selected.issues, items: Object.entries(issues).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -69,8 +76,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: 'Les réseaux de chaleur en pratique : tout comprendre pour se raccorder', - isActive: Object.keys(understandings).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.understandings, + expandedByDefault: selected.understandings, items: Object.entries(understandings).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -82,8 +89,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: 'Une filière en pleine croissance', - isActive: Object.keys(growths).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.growths, + expandedByDefault: selected.growths, items: Object.entries(growths).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -95,8 +102,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: "Les réseaux de froid, un enjeu pour l'avenir", - isActive: Object.keys(coldNetworks).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.coldNetworks, + expandedByDefault: selected.coldNetworks, items: Object.entries(coldNetworks).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key,