Files
web/apps/scandic-web/components/Blocks/CampaignHotelListing/index.tsx
Joakim Jäderberg bf6ed7778e Merged in feat/syncDefaultMessage (pull request #3022)
Sync defaultMessage from lokalise

* Enhance translation sync functionality and tests

- Added logging for found component files during sync.
- Introduced tests for handling complex components with replacements.
- Updated regex in syncIntlFormatMessage to support optional second arguments.
- Removed unused test files.

* feat(syncDefaultMessage): add script for syncing default message with lokalise

* feat(syncDefaultMessage): add script for syncing default message with lokalise


Approved-by: Matilda Landström
2025-10-30 08:38:50 +00:00

82 lines
2.1 KiB
TypeScript

import { Suspense } from "react"
import {
type HotelSortItem,
HotelSortOption,
} from "@scandic-hotels/trpc/types/hotel"
import { getFiltersFromHotels } from "@scandic-hotels/trpc/utils/getFiltersFromHotels"
import { getHotelsByCSFilter } from "@/lib/trpc/memoizedRequests"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import HotelListingDataProvider from "@/providers/HotelListingDataProvider"
import CampaignHotelListingSkeleton from "./CampaignHotelListingSkeleton"
import CampaignHotelListingClient from "./Client"
interface CampaignHotelListingProps {
heading: string
preamble?: string | null
hotelIds: string[]
bookingCode?: string | null
visibleCountMobile?: 3 | 6
visibleCountDesktop?: 3 | 6
isMainBlock?: boolean
}
export default async function CampaignHotelListing({
heading,
preamble,
hotelIds,
bookingCode,
visibleCountMobile = 3,
visibleCountDesktop = 6,
isMainBlock = false,
}: CampaignHotelListingProps) {
const intl = await getIntl()
const lang = await getLang()
const hotels = await getHotelsByCSFilter({ hotelsToInclude: hotelIds })
if (!hotels.length) {
return null
}
const allFilters = getFiltersFromHotels(hotels, lang)
const sortItems: HotelSortItem[] = [
{
label: intl.formatMessage({
id: "common.name",
defaultMessage: "Name",
}),
value: HotelSortOption.Name,
},
{
label: intl.formatMessage({
id: "common.tripAdvisorRating",
defaultMessage: "Tripadvisor rating",
}),
value: HotelSortOption.TripAdvisorRating,
},
]
return (
<Suspense fallback={<CampaignHotelListingSkeleton />}>
<HotelListingDataProvider
allHotels={hotels}
allFilters={allFilters}
sortItems={sortItems}
>
<CampaignHotelListingClient
heading={heading}
preamble={preamble}
bookingCode={bookingCode}
visibleCountMobile={visibleCountMobile}
visibleCountDesktop={visibleCountDesktop}
isMainBlock={isMainBlock}
/>
</HotelListingDataProvider>
</Suspense>
)
}