Skip to content

Commit

Permalink
Initialize slider value based on material type in URL on work page
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamik10 committed Dec 4, 2024
1 parent 068e259 commit f3f2b67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/pages/workPageLayout/WorkPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ const WorkPageHeader = ({ work }: WorkPageHeaderProps) => {
undefined
)
const findInitialSliderValue = () => {
const searchParams = new URLSearchParams(window.location.search)
// If we have a material type specified in the URL, we use that
if (
searchParams.has("type") &&
slideSelectOptions.some(option => option.render === searchParams.get("type"))
) {
return slideSelectOptions.find(option => option.render === searchParams.get("type"))
}
return slideSelectOptions.find(option => {
return selectedManifestation?.materialTypes.find(materialType => {
return materialType.materialTypeGeneral.code.includes(option.value)
Expand Down

0 comments on commit f3f2b67

Please sign in to comment.