diff --git a/src/components/structure/Sidebar/subComponents/Accordion/AccordionComponent.tsx b/src/components/structure/Sidebar/subComponents/Accordion/AccordionComponent.tsx index f1f9befe..a295724e 100644 --- a/src/components/structure/Sidebar/subComponents/Accordion/AccordionComponent.tsx +++ b/src/components/structure/Sidebar/subComponents/Accordion/AccordionComponent.tsx @@ -7,6 +7,7 @@ import { AccordionIcon, AccordionPanel, } from "@chakra-ui/react"; +import { useEffect, useState } from "react"; import { MdRule } from "react-icons/md"; import { LuFileSearch, LuFileCheck2 } from "react-icons/lu"; @@ -50,7 +51,7 @@ const AccordionComponent = () => { }, { path: `/review/planning/protocol/picoc/${id}`, - label: "PICOC" + label: "PICOC", }, { path: `/review/planning/protocol/research-questions/${id}`, @@ -99,10 +100,25 @@ const AccordionComponent = () => { ], }; + const sectionToIndex: Record = { + Planning: 0, + Execution: 1, + Summarization: 2, + }; + + const [localIndex, setLocalIndex] = useState( + sectionToIndex[activeSection as string] ?? -1, + ); + + useEffect(() => { + const newIndex = sectionToIndex[activeSection as string] ?? -1; + setLocalIndex(newIndex); + }, [activeSection]); + return ( - + setLocalIndex(expandedIndex)}> {Object.entries(sections).map(([section, children]) => ( - +

syncAndNavigate( - `/review/planning/protocol/eligibility-criteria/${id}` + `/review/planning/protocol/eligibility-criteria/${id}`, ) } text="Back" @@ -36,7 +36,7 @@ export default function InformationSourcesAndSearchStrategy() { syncAndNavigate( - `/review/planning/protocol/selection-and-extraction/${id}` + `/review/planning/protocol/selection-and-extraction/${id}`, ) } text="Next" @@ -50,7 +50,7 @@ export default function InformationSourcesAndSearchStrategy() { onChange={(event) => { handleChangeInformationSourcesAndSearchStrategy( "sourcesSelectionCriteria", - event.target.value + event.target.value, ); }} label="Sources Selection Criteria" @@ -59,17 +59,25 @@ export default function InformationSourcesAndSearchStrategy() { { handleChangeInformationSourcesAndSearchStrategy( "searchMethod", - event.target.value + event.target.value, ); }} label="Search Strategy" @@ -93,7 +101,7 @@ export default function InformationSourcesAndSearchStrategy() { onChange={(event) => { handleChangeInformationSourcesAndSearchStrategy( "searchString", - event.target.value + event.target.value, ); }} label="Search String"