diff --git a/src/utils/useNavigation.ts b/src/utils/useNavigation.ts index 204956bdf3724a559bcb8e41938c3501b5692708..293857dfa64d2a1ddb67f27c70b14e1456eb8deb 100644 --- a/src/utils/useNavigation.ts +++ b/src/utils/useNavigation.ts @@ -10,6 +10,16 @@ export const useNavigation = () => { const goToTextsAndOpenCollapsible = (collapseId: string, path: string) => { navigate(`${path}${collapseId}`); }; - - return { goToPagesAndOpenTab, goToTextsAndOpenCollapsible }; + const goToPageWithTabAndCollapsible = ({ path, tabId, collapseId }: { path: string, tabId: string, collapseId?: string }) => { + const navigate = useNavigate(); + navigate(`${path}?tab=${tabId}${collapseId ? `&collapseId=${collapseId}` : ''}`); + }; +/* <a onClick={() => goToPageWithTabAndCollapsible({ + path: "/human-practices", + tabId: "InvWesthoff", + collapseId: "collapse-1" // ID of the collapsible to open +})}> + Go to Human Practices and Open Collapsible 1 +</a> */ + return { goToPagesAndOpenTab, goToTextsAndOpenCollapsible, goToPageWithTabAndCollapsible }; }; \ No newline at end of file