Skip to content

Commit

Permalink
(feature) updated breadcrumbs to include time frame parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mdewey committed Dec 27, 2024
1 parent bf52b26 commit c3f13bb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ const MrBreadcrumbs = () => {
);

const textContent = document.querySelector('h1')?.textContent;
const searchIndex = new URLSearchParams(window.location.search);
const searchIndex = new URLSearchParams(location.search);
const page = searchIndex.get('page');
const { labId } = useParams();

const urlVitalsDate = searchIndex.get('timeFrame');

useEffect(
() => {
if (page) dispatch(setPageNumber(+page));
Expand Down Expand Up @@ -62,6 +64,15 @@ const MrBreadcrumbs = () => {
)}?page=${pageNumber}`,
};
dispatch(setBreadcrumbs([backToPageNumCrumb, detailCrumb]));
} else if (urlVitalsDate) {
const backToVitalsDateCrumb = {
...Breadcrumbs[feature],
href: `${Breadcrumbs[feature].href.slice(
0,
-1,
)}?timeFrame=${urlVitalsDate}`,
};
dispatch(setBreadcrumbs([backToVitalsDateCrumb, detailCrumb]));
} else {
dispatch(setBreadcrumbs([Breadcrumbs[feature], detailCrumb]));
}
Expand Down

0 comments on commit c3f13bb

Please sign in to comment.