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:
+8
-16
@@ -2,7 +2,6 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|||||||
|
|
||||||
import AccordionItem from "@/components/TempDesignSystem/Accordion/AccordionItem"
|
import AccordionItem from "@/components/TempDesignSystem/Accordion/AccordionItem"
|
||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
|
|
||||||
import styles from "./destination.module.css"
|
import styles from "./destination.module.css"
|
||||||
@@ -30,21 +29,14 @@ export default async function Destination({
|
|||||||
{cities.map((city) =>
|
{cities.map((city) =>
|
||||||
city.hotelCount > 0 ? (
|
city.hotelCount > 0 ? (
|
||||||
<li key={city.id}>
|
<li key={city.id}>
|
||||||
{city.url ? (
|
<Link
|
||||||
<Link
|
href={city.url}
|
||||||
href={city.url}
|
color="baseTextMediumContrast"
|
||||||
color="baseTextMediumContrast"
|
textDecoration="underline"
|
||||||
textDecoration="underline"
|
>
|
||||||
>
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
{`${city.name} (${city.hotelCount})`}
|
||||||
{`${city.name} (${city.hotelCount})`}
|
</Link>
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
|
||||||
<Body>{`${city.name} (${city.hotelCount})`}</Body>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</li>
|
</li>
|
||||||
) : null
|
) : null
|
||||||
)}
|
)}
|
||||||
|
|||||||
+671
-794
File diff suppressed because it is too large
Load Diff
+661
-784
File diff suppressed because it is too large
Load Diff
+683
-800
File diff suppressed because it is too large
Load Diff
+671
-794
File diff suppressed because it is too large
Load Diff
+659
-782
File diff suppressed because it is too large
Load Diff
+699
-822
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ import {
|
|||||||
} from "./output"
|
} from "./output"
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
Cities,
|
City,
|
||||||
DestinationsData,
|
DestinationsData,
|
||||||
} from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
|
} from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
|
||||||
import {
|
import {
|
||||||
@@ -212,28 +212,33 @@ export const destinationOverviewPageQueryRouter = router({
|
|||||||
|
|
||||||
const destinations = await Promise.all(
|
const destinations = await Promise.all(
|
||||||
Object.entries(citiesByCountry).map(async ([country, cities]) => {
|
Object.entries(citiesByCountry).map(async ([country, cities]) => {
|
||||||
const activeCitiesWithHotelCount: Cities = await Promise.all(
|
const activeCitiesWithHotelCount: (City | null)[] =
|
||||||
cities.map(async (city) => {
|
await Promise.all(
|
||||||
const [hotels] = await safeTry(
|
cities.map(async (city) => {
|
||||||
getHotelIdsByCityId({
|
const [hotels] = await safeTry(
|
||||||
cityId: city.id,
|
getHotelIdsByCityId({
|
||||||
serviceToken: ctx.serviceToken,
|
cityId: city.id,
|
||||||
})
|
serviceToken: ctx.serviceToken,
|
||||||
)
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const cityPage = cityPages.find(
|
const cityPage = cityPages.find(
|
||||||
(cityPage) => cityPage.city === city.cityIdentifier
|
(cityPage) => cityPage.city === city.cityIdentifier
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return cityPage?.url
|
||||||
id: city.id,
|
? {
|
||||||
name: city.name,
|
id: city.id,
|
||||||
hotelIds: hotels || [],
|
name: city.name,
|
||||||
hotelCount: hotels ? hotels.length : 0,
|
hotelIds: hotels || [],
|
||||||
url: cityPage?.url,
|
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 countryPages = await getCountryPageUrls(lang)
|
||||||
const countryPage = countryPages.find(
|
const countryPage = countryPages.find(
|
||||||
@@ -243,11 +248,11 @@ export const destinationOverviewPageQueryRouter = router({
|
|||||||
return {
|
return {
|
||||||
country,
|
country,
|
||||||
countryUrl: countryPage?.url,
|
countryUrl: countryPage?.url,
|
||||||
numberOfHotels: activeCitiesWithHotelCount.reduce(
|
numberOfHotels: filteredActiveCitiesWithHotelCount.reduce(
|
||||||
(acc, city) => acc + city.hotelCount,
|
(acc, city) => acc + city.hotelCount,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
cities: activeCitiesWithHotelCount,
|
cities: filteredActiveCitiesWithHotelCount,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-4
@@ -3,7 +3,7 @@ export type City = {
|
|||||||
name: string
|
name: string
|
||||||
hotelIds: string[]
|
hotelIds: string[]
|
||||||
hotelCount: number
|
hotelCount: number
|
||||||
url?: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DestinationCountry = {
|
export type DestinationCountry = {
|
||||||
@@ -15,8 +15,6 @@ export type DestinationCountry = {
|
|||||||
|
|
||||||
export type DestinationsData = DestinationCountry[]
|
export type DestinationsData = DestinationCountry[]
|
||||||
|
|
||||||
export type Cities = DestinationCountry["cities"]
|
|
||||||
|
|
||||||
export type DestinationsListProps = {
|
export type DestinationsListProps = {
|
||||||
destinations: DestinationsData
|
destinations: DestinationsData
|
||||||
}
|
}
|
||||||
@@ -25,5 +23,5 @@ export type DestinationProps = {
|
|||||||
country: string
|
country: string
|
||||||
countryUrl: string | undefined
|
countryUrl: string | undefined
|
||||||
numberOfHotels: number
|
numberOfHotels: number
|
||||||
cities: Cities
|
cities: DestinationCountry["cities"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user