Newer
Older
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import { openFromOtherPage } from "../utils/openFromOtherpAge";
Liliana Sanfilippo
committed
import { openNestedTab, openTab, handleScrollToCollapse } from "../utils/TabNavigation";
import { LoremMedium } from "../components/Loremipsum";
import { Section, Subesction } from "./sections";
Liliana Sanfilippo
committed
const location = useLocation();
useEffect(() => {
Liliana Sanfilippo
committed
const params = new URLSearchParams(location.search);
const collapseId = params.get('collapseId');
const tabId = params.get('tab');
const subTabId = params.get('subTab'); // Neues Parameter für verschachtelte Tabs
// Open the tab specified by tabId (and subTab if nested)
if (tabId) {
if (subTabId) {
// If subTab is provided, open the nested tab
openNestedTab(tabId, subTabId);
} else {
// Otherwise, just open the main tab
openTab(tabId);
Liliana Sanfilippo
committed
}
// Scroll to the section specified by collapseId after opening the tab
if (collapseId) {
handleScrollToCollapse(collapseId);
}
// Open the tab from another page
if (tabId) {
openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
}
Liliana Sanfilippo
committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<Section title="Role in iGem" id="Role">
<LoremMedium/>
</Section>
<Section title="Check-Ins" id="Check-Ins">
<LoremMedium/>
</Section>
<Section title="Our Lab" id="Our Lab">
<LoremMedium/>
</Section>
<Section title="Biosafety" id="Biosafety">
<Subesction title="Mechanism" id="Biosafety1">
<LoremMedium/>
</Subesction>
<Subesction title="Delivery" id="Biosafety2">
<LoremMedium/>
</Subesction>
</Section>
<Section title="Biosecurity" id="Biosecurity">
<Subesction title="Our Project" id="Biosecurity1">
<LoremMedium/>
</Subesction>
<Subesction title="Risk Assesment" id="Biosecurity2">
<LoremMedium/>
</Subesction>
<Subesction title="Managing Risks" id="Biosecurity3">
<LoremMedium/>
</Subesction>
</Section>
<Section title="Bioethics" id="Bioethics">
<Subesction title="Gene Therapy" id="Bioethics1">
<LoremMedium/>
</Subesction>
<Subesction title="Primary Cells" id="Bioethics2">
<LoremMedium/>
</Subesction>
<Subesction title="Consent and Guidelines" id="Bioethics3">
<LoremMedium/>
</Subesction>
</Section>