fix(SW-1971): now closes mobile menu on clicking the find booking link

removed useless class usage

added customer service url to link
This commit is contained in:
Christian Andolf
2025-03-19 16:31:38 +01:00
parent 0666b62a4c
commit 9a37a2f4c0
4 changed files with 40 additions and 30 deletions

View File

@@ -1,3 +1,5 @@
"use client"
import Link from "next/link"
import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name"
@@ -12,11 +14,12 @@ export default function HeaderLink({
href,
iconName,
iconSize = 20,
onClick = () => undefined,
}: HeaderLinkProps) {
const Icon = getIconByIconName(iconName)
return (
<Caption type="regular" color="textMediumContrast" asChild>
<Link href={href} className={styles.headerLink}>
<Link href={href} className={styles.headerLink} onClick={onClick}>
{Icon ? (
<Icon className={styles.icon} width={iconSize} height={iconSize} />
) : null}

View File

@@ -5,6 +5,7 @@ import { Dialog, Modal } from "react-aria-components"
import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
import { customerService } from "@/constants/currentWebHrefs"
import { findMyBooking } from "@/constants/routes/findMyBooking"
import useDropdownStore from "@/stores/main-menu"
@@ -86,11 +87,18 @@ export default function MobileMenu({
>
{children}
<footer className={styles.footer}>
<HeaderLink href={findMyBooking[lang]} iconName={IconName.Search}>
<HeaderLink
href={findMyBooking[lang]}
iconName={IconName.Search}
onClick={() => toggleDropdown(DropdownTypeEnum.HamburgerMenu)}
>
{intl.formatMessage({ id: "Find booking" })}
</HeaderLink>
<TopLink isLoggedIn={isLoggedIn} topLink={topLink} iconSize={20} />
<HeaderLink href="#" iconName={IconName.Service}>
<HeaderLink
href={customerService[lang]}
iconName={IconName.Service}
>
{intl.formatMessage({ id: "Customer service" })}
</HeaderLink>
<LanguageSwitcher type="mobileHeader" />

View File

@@ -30,33 +30,31 @@ export default function LanguageSwitcherContent({
return (
<FocusTrap focusTrapOptions={{ clickOutsideDeactivates: true }}>
<div className={styles.languageSwitcherContent}>
<div className={styles.languageWrapper}>
<Subtitle className={styles.subtitle} type="two">
{intl.formatMessage({ id: "Select your language" })}
</Subtitle>
<ul className={styles.list}>
{urlKeys.map((key) => {
const url = urls[key]?.url
const isActive = currentLanguage === key
if (url) {
return (
<li key={key}>
<Link
className={`${styles.link} ${isActive ? styles.active : ""}`}
href={replaceUrlPart(pathname, url)}
onClick={onLanguageSwitch}
keepSearchParams
>
{languages[key]}
{isActive ? <CheckIcon color="burgundy" /> : null}
</Link>
</li>
)
}
})}
</ul>
</div>
<div className={styles.languageWrapper}>
<Subtitle className={styles.subtitle} type="two">
{intl.formatMessage({ id: "Select your language" })}
</Subtitle>
<ul className={styles.list}>
{urlKeys.map((key) => {
const url = urls[key]?.url
const isActive = currentLanguage === key
if (url) {
return (
<li key={key}>
<Link
className={`${styles.link} ${isActive ? styles.active : ""}`}
href={replaceUrlPart(pathname, url)}
onClick={onLanguageSwitch}
keepSearchParams
>
{languages[key]}
{isActive ? <CheckIcon color="burgundy" /> : null}
</Link>
</li>
)
}
})}
</ul>
</div>
</FocusTrap>
)

View File

@@ -6,4 +6,5 @@ export interface HeaderLinkProps extends React.PropsWithChildren {
href: LinkProps["href"]
iconName: IconName | null
iconSize?: number
onClick?: VoidFunction
}