refactor(SW-302): code cleanup

This commit is contained in:
Matilda Landström
2024-09-19 13:26:05 +02:00
parent 2438d04f43
commit 72c961eabf
9 changed files with 65 additions and 37 deletions

View File

@@ -11,11 +11,11 @@ import {
type Facilities,
type FacilityCards,
FacilityEnum,
RestaurantHeadings,
} from "@/types/components/hotelPage/facilities"
import type { ImageVaultAsset } from "@/types/components/imageVault"
import type { HotelData } from "@/types/hotel"
import type { Amenities, Facility } from "@/types/hotel"
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
import type { Facility } from "@/server/routers/hotels/output"
type ActivityCard = {
background_image?: ImageVaultAsset
@@ -55,8 +55,8 @@ export function setActivityCard(activitiesCard: ActivityCard): FacilityCards {
}
export async function setFacilityCards(
facilities: Array<Facility>,
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
facilities: Facility[],
amenities: Amenities
) {
const lang = getLang()
const intl = await getIntl()
@@ -135,28 +135,27 @@ export async function setFacilityCards(
return cards
}
export function getRestaurantHeading(
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
) {
export function getRestaurantHeading(amenities: Amenities): RestaurantHeadings {
const hasBar = amenities.some(
(facility) => facility.id == 1606 || facility.id == 1014 // bar & rooftop bar id
)
const hasRestaurant = amenities.some((facility) => facility.id == 1383) // restaurant id
//let href,
let title: string
let title: RestaurantHeadings
if (hasBar && hasRestaurant) {
//href = restaurantAndBar
title = "Restaurant & Bar"
title = RestaurantHeadings.restaurantAndBar
} else if (hasBar) {
//href = bar
title = "Bar"
title = RestaurantHeadings.bar
} else if (hasRestaurant) {
//href = restaurant
title = "Restaurant"
title = RestaurantHeadings.restaurant
} else {
//href = breakfastRestaurant
title = "Breakfast restaurant"
title = RestaurantHeadings.breakfastRestaurant
}
return title
}