Merged in feat/SW-2220-destination-list (pull request #1851)
Feat/SW-2220 destination list * fix(SW-2220): remove old hotels * fix(SW-2220): add filtering of cities without urls * fix(SW-2220): destinations English * fix(SW-2220): update all country files * refactor(SW-2220): cleanup Approved-by: Michael Zetterberg Approved-by: Erik Tiekstra
This commit is contained in:
@@ -2,7 +2,6 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
|
||||
import AccordionItem from "@/components/TempDesignSystem/Accordion/AccordionItem"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import { getIntl } from "@/i18n"
|
||||
|
||||
import styles from "./destination.module.css"
|
||||
@@ -30,21 +29,14 @@ export default async function Destination({
|
||||
{cities.map((city) =>
|
||||
city.hotelCount > 0 ? (
|
||||
<li key={city.id}>
|
||||
{city.url ? (
|
||||
<Link
|
||||
href={city.url}
|
||||
color="baseTextMediumContrast"
|
||||
textDecoration="underline"
|
||||
>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{`${city.name} (${city.hotelCount})`}
|
||||
</Link>
|
||||
) : (
|
||||
<>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
<Body>{`${city.name} (${city.hotelCount})`}</Body>
|
||||
</>
|
||||
)}
|
||||
<Link
|
||||
href={city.url}
|
||||
color="baseTextMediumContrast"
|
||||
textDecoration="underline"
|
||||
>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
{`${city.name} (${city.hotelCount})`}
|
||||
</Link>
|
||||
</li>
|
||||
) : null
|
||||
)}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ import {
|
||||
} from "./output"
|
||||
|
||||
import type {
|
||||
Cities,
|
||||
City,
|
||||
DestinationsData,
|
||||
} from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
|
||||
import {
|
||||
@@ -212,28 +212,33 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
|
||||
const destinations = await Promise.all(
|
||||
Object.entries(citiesByCountry).map(async ([country, cities]) => {
|
||||
const activeCitiesWithHotelCount: Cities = await Promise.all(
|
||||
cities.map(async (city) => {
|
||||
const [hotels] = await safeTry(
|
||||
getHotelIdsByCityId({
|
||||
cityId: city.id,
|
||||
serviceToken: ctx.serviceToken,
|
||||
})
|
||||
)
|
||||
const activeCitiesWithHotelCount: (City | null)[] =
|
||||
await Promise.all(
|
||||
cities.map(async (city) => {
|
||||
const [hotels] = await safeTry(
|
||||
getHotelIdsByCityId({
|
||||
cityId: city.id,
|
||||
serviceToken: ctx.serviceToken,
|
||||
})
|
||||
)
|
||||
|
||||
const cityPage = cityPages.find(
|
||||
(cityPage) => cityPage.city === city.cityIdentifier
|
||||
)
|
||||
const cityPage = cityPages.find(
|
||||
(cityPage) => cityPage.city === city.cityIdentifier
|
||||
)
|
||||
|
||||
return {
|
||||
id: city.id,
|
||||
name: city.name,
|
||||
hotelIds: hotels || [],
|
||||
hotelCount: hotels ? hotels.length : 0,
|
||||
url: cityPage?.url,
|
||||
}
|
||||
})
|
||||
)
|
||||
return cityPage?.url
|
||||
? {
|
||||
id: city.id,
|
||||
name: city.name,
|
||||
hotelIds: hotels || [],
|
||||
hotelCount: hotels ? hotels.length : 0,
|
||||
url: cityPage.url,
|
||||
}
|
||||
: null
|
||||
})
|
||||
)
|
||||
const filteredActiveCitiesWithHotelCount: City[] =
|
||||
activeCitiesWithHotelCount.filter((c): c is City => !!c)
|
||||
|
||||
const countryPages = await getCountryPageUrls(lang)
|
||||
const countryPage = countryPages.find(
|
||||
@@ -243,11 +248,11 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
return {
|
||||
country,
|
||||
countryUrl: countryPage?.url,
|
||||
numberOfHotels: activeCitiesWithHotelCount.reduce(
|
||||
numberOfHotels: filteredActiveCitiesWithHotelCount.reduce(
|
||||
(acc, city) => acc + city.hotelCount,
|
||||
0
|
||||
),
|
||||
cities: activeCitiesWithHotelCount,
|
||||
cities: filteredActiveCitiesWithHotelCount,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ export type City = {
|
||||
name: string
|
||||
hotelIds: string[]
|
||||
hotelCount: number
|
||||
url?: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export type DestinationCountry = {
|
||||
@@ -15,8 +15,6 @@ export type DestinationCountry = {
|
||||
|
||||
export type DestinationsData = DestinationCountry[]
|
||||
|
||||
export type Cities = DestinationCountry["cities"]
|
||||
|
||||
export type DestinationsListProps = {
|
||||
destinations: DestinationsData
|
||||
}
|
||||
@@ -25,5 +23,5 @@ export type DestinationProps = {
|
||||
country: string
|
||||
countryUrl: string | undefined
|
||||
numberOfHotels: number
|
||||
cities: Cities
|
||||
cities: DestinationCountry["cities"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user