refactor(feat-SW-94): use enum for HotelHashValues and move to types/components dir

This commit is contained in:
Chuma McPhoy
2024-08-12 13:51:05 +02:00
parent ae066d850e
commit b19dbf0664
3 changed files with 20 additions and 18 deletions

View File

@@ -4,27 +4,28 @@ import { useIntl } from "react-intl"
import Link from "@/components/TempDesignSystem/Link"
import useHash from "@/hooks/useHash"
import { HotelHashValues } from "./types"
import styles from "./tabNavigation.module.css"
import { HotelHashValues } from "@/types/components/hotelPage/tabNavigation"
export default function TabNavigation() {
const hash = useHash()
const { formatMessage } = useIntl()
const hotelTabLinks: { href: HotelHashValues; text: string }[] = [
{ href: "#overview", text: "Overview" },
{ href: "#rooms-section", text: "Rooms" },
{ href: "#restaurant-and-bar", text: "Restaurant & Bar" },
{ href: "#meetings-and-conferences", text: "Meetings & Conferences" },
{ href: "#wellness-and-exercise", text: "Wellness & Exercise" },
{ href: "#activities", text: "Activities" },
{ href: "#faq", text: "FAQ" },
{ href: HotelHashValues.overview, text: "Overview" },
{ href: HotelHashValues.rooms, text: "Rooms" },
{ href: HotelHashValues.restaurant, text: "Restaurant & Bar" },
{ href: HotelHashValues.meetings, text: "Meetings & Conferences" },
{ href: HotelHashValues.wellness, text: "Wellness & Exercise" },
{ href: HotelHashValues.activities, text: "Activities" },
{ href: HotelHashValues.faq, text: "FAQ" },
]
return (
<nav className={styles.tabsContainer}>
{hotelTabLinks.map((link) => {
const isActive =
hash === link.href || (hash === "" && link.href === "#overview")
hash === link.href ||
(hash === "" && link.href === HotelHashValues.overview)
return (
<Link
key={link.href}

View File

@@ -1,8 +0,0 @@
export type HotelHashValues =
| "#overview"
| "#rooms-section"
| "#restaurant-and-bar"
| "#meetings-and-conferences"
| "#wellness-and-exercise"
| "#activities"
| "#faq"

View File

@@ -0,0 +1,9 @@
export enum HotelHashValues {
overview = "#overview",
rooms = "#rooms-section",
restaurant = "#restaurant-and-bar",
meetings = "#meetings-and-conferences",
wellness = "#wellness-and-exercise",
activities = "#activities",
faq = "#faq",
}