feat(SW-441): Added dynamic values for activities and faq to tabNavigation
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import { useEffect } from "react"
|
import { useEffect } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
@@ -14,13 +15,16 @@ import {
|
|||||||
type TabNavigationProps,
|
type TabNavigationProps,
|
||||||
} from "@/types/components/hotelPage/tabNavigation"
|
} from "@/types/components/hotelPage/tabNavigation"
|
||||||
|
|
||||||
export default function TabNavigation({ restaurantTitle }: TabNavigationProps) {
|
export default function TabNavigation({
|
||||||
|
restaurantTitle,
|
||||||
|
hasActivities,
|
||||||
|
hasFAQ,
|
||||||
|
}: TabNavigationProps) {
|
||||||
const hash = useHash()
|
const hash = useHash()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
// const [isObserverActive, setIsObserverActive] = useState<boolean>(true)
|
|
||||||
|
|
||||||
const hotelTabLinks: { hash: HotelHashValues | string; text: string }[] = [
|
const tabLinks: { hash: HotelHashValues; text: string }[] = [
|
||||||
{
|
{
|
||||||
hash: HotelHashValues.overview,
|
hash: HotelHashValues.overview,
|
||||||
text: intl.formatMessage({ id: "Overview" }),
|
text: intl.formatMessage({ id: "Overview" }),
|
||||||
@@ -38,15 +42,26 @@ export default function TabNavigation({ restaurantTitle }: TabNavigationProps) {
|
|||||||
hash: HotelHashValues.wellness,
|
hash: HotelHashValues.wellness,
|
||||||
text: intl.formatMessage({ id: "Wellness & Exercise" }),
|
text: intl.formatMessage({ id: "Wellness & Exercise" }),
|
||||||
},
|
},
|
||||||
{
|
...(hasActivities
|
||||||
hash: HotelHashValues.activities,
|
? [
|
||||||
text: intl.formatMessage({ id: "Activities" }),
|
{
|
||||||
},
|
hash: HotelHashValues.activities,
|
||||||
{ hash: HotelHashValues.faq, text: intl.formatMessage({ id: "FAQ" }) },
|
text: intl.formatMessage({ id: "Activities" }),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...(hasFAQ
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
hash: HotelHashValues.faq,
|
||||||
|
text: intl.formatMessage({ id: "FAQ" }),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
]
|
]
|
||||||
|
|
||||||
const { activeSectionId, pauseScrollSpy } = useScrollSpy(
|
const { activeSectionId, pauseScrollSpy } = useScrollSpy(
|
||||||
hotelTabLinks.map(({ hash }) => hash)
|
tabLinks.map(({ hash }) => hash)
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -58,7 +73,7 @@ export default function TabNavigation({ restaurantTitle }: TabNavigationProps) {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.stickyWrapper}>
|
<div className={styles.stickyWrapper}>
|
||||||
<nav className={styles.tabsContainer}>
|
<nav className={styles.tabsContainer}>
|
||||||
{hotelTabLinks.map((link) => {
|
{tabLinks.map((link) => {
|
||||||
const isActive =
|
const isActive =
|
||||||
hash === link.hash ||
|
hash === link.hash ||
|
||||||
(!hash && link.hash === HotelHashValues.overview)
|
(!hash && link.hash === HotelHashValues.overview)
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ export default async function HotelPage() {
|
|||||||
</div>
|
</div>
|
||||||
<TabNavigation
|
<TabNavigation
|
||||||
restaurantTitle={getRestaurantHeading(hotelDetailedFacilities)}
|
restaurantTitle={getRestaurantHeading(hotelDetailedFacilities)}
|
||||||
|
hasActivities={!!activitiesCard}
|
||||||
|
hasFAQ={false}
|
||||||
/>
|
/>
|
||||||
<main className={styles.mainSection}>
|
<main className={styles.mainSection}>
|
||||||
<div id={HotelHashValues.overview} className={styles.introContainer}>
|
<div id={HotelHashValues.overview} className={styles.introContainer}>
|
||||||
|
|||||||
@@ -10,4 +10,6 @@ export enum HotelHashValues {
|
|||||||
|
|
||||||
export type TabNavigationProps = {
|
export type TabNavigationProps = {
|
||||||
restaurantTitle: string
|
restaurantTitle: string
|
||||||
|
hasActivities: boolean
|
||||||
|
hasFAQ: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user