Merged in feat/sw-2873-move-selecthotel-to-booking-flow (pull request #2727)
feat(SW-2873): Move select-hotel to booking flow * crude setup of select-hotel in partner-sas * wip * Fix linting * restructure tracking files * Remove dependency on trpc in tracking hooks * Move pageview tracking to common * Fix some lint and import issues * Add AlternativeHotelsPage * Add SelectHotelMapPage * Add AlternativeHotelsMapPage * remove next dependency in tracking store * Remove dependency on react in tracking hooks * move isSameBooking to booking-flow * Inject searchParamsComparator into tracking store * Move useTrackHardNavigation to common * Move useTrackSoftNavigation to common * Add TrackingSDK to partner-sas * call serverclient in layout * Remove unused css * Update types * Move HotelPin type * Fix todos * Merge branch 'master' into feat/sw-2873-move-selecthotel-to-booking-flow * Merge branch 'master' into feat/sw-2873-move-selecthotel-to-booking-flow * Fix component Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { isDefined } from "@scandic-hotels/common/utils/isDefined"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import { cache } from "@/utils/cache"
|
||||
|
||||
import { serverClient } from "../server"
|
||||
@@ -12,22 +9,13 @@ import type { GetHotelsByCSFilterInput } from "@scandic-hotels/trpc/routers/hote
|
||||
import type { GetSavedPaymentCardsInput } from "@scandic-hotels/trpc/routers/user/input"
|
||||
import type { RoomsAvailabilityExtendedInputSchema } from "@scandic-hotels/trpc/types/availability"
|
||||
import type { Country } from "@scandic-hotels/trpc/types/country"
|
||||
import type {
|
||||
CityCoordinatesInput,
|
||||
HotelInput,
|
||||
} from "@scandic-hotels/trpc/types/hotel"
|
||||
import type { HotelInput } from "@scandic-hotels/trpc/types/hotel"
|
||||
import type {
|
||||
AncillaryPackagesInput,
|
||||
BreackfastPackagesInput,
|
||||
PackagesInput,
|
||||
} from "@scandic-hotels/trpc/types/packages"
|
||||
|
||||
export const getLocations = cache(async function getMemoizedLocations() {
|
||||
const lang = await getLang()
|
||||
const caller = await serverClient()
|
||||
return caller.hotel.locations.get({ lang })
|
||||
})
|
||||
|
||||
export const getProfile = cache(async function getMemoizedProfile() {
|
||||
const caller = await serverClient()
|
||||
return caller.user.get()
|
||||
@@ -187,13 +175,6 @@ export const getLinkedReservations = cache(
|
||||
}
|
||||
)
|
||||
|
||||
export const getCityCoordinates = cache(
|
||||
async function getMemoizedCityCoordinates(input: CityCoordinatesInput) {
|
||||
const caller = await serverClient()
|
||||
return caller.hotel.map.city(input)
|
||||
}
|
||||
)
|
||||
|
||||
export const getCurrentRewards = cache(
|
||||
async function getMemoizedCurrentRewards() {
|
||||
const caller = await serverClient()
|
||||
@@ -294,83 +275,6 @@ export const getJobylonFeed = cache(async function getMemoizedJobylonFeed() {
|
||||
return caller.partner.jobylon.feed.get()
|
||||
})
|
||||
|
||||
export const getJumpToData = cache(async function getMemoizedJumpToData() {
|
||||
const lang = await getLang()
|
||||
const caller = await serverClient()
|
||||
const [locationsResults, urlsResults] = await Promise.allSettled([
|
||||
getLocations(),
|
||||
caller.hotel.locations.urls({ lang }),
|
||||
])
|
||||
|
||||
if (
|
||||
locationsResults.status === "fulfilled" &&
|
||||
urlsResults.status === "fulfilled"
|
||||
) {
|
||||
const locations = locationsResults.value
|
||||
const urls = urlsResults.value
|
||||
|
||||
if (!locations || !urls) {
|
||||
return null
|
||||
}
|
||||
|
||||
return locations
|
||||
.map((location) => {
|
||||
const { id, name, type } = location
|
||||
|
||||
const isCity = type === "cities"
|
||||
const isHotel = type === "hotels"
|
||||
|
||||
let url: string | undefined
|
||||
|
||||
if (isCity) {
|
||||
url = urls.cities.find(
|
||||
(c) =>
|
||||
c.city &&
|
||||
location.cityIdentifier &&
|
||||
c.city === location.cityIdentifier
|
||||
)?.url
|
||||
} else if (isHotel) {
|
||||
url = urls.hotels.find(
|
||||
(h) => h.hotelId && location.id && h.hotelId === location.id
|
||||
)?.url
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
return null
|
||||
}
|
||||
|
||||
let description = ""
|
||||
if (isCity) {
|
||||
description = location.country
|
||||
} else if (isHotel) {
|
||||
description = location.relationships.city.name
|
||||
}
|
||||
|
||||
const rankingNames: string[] = [location.name]
|
||||
if (isCity) {
|
||||
if (location.cityIdentifier) {
|
||||
rankingNames.push(location.cityIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
const rankingKeywords = location.keyWords || []
|
||||
|
||||
return {
|
||||
id,
|
||||
displayName: name,
|
||||
type,
|
||||
description,
|
||||
url,
|
||||
rankingNames: rankingNames.map((v) => v.toLowerCase()),
|
||||
rankingKeywords: rankingKeywords.map((v) => v.toLowerCase()),
|
||||
}
|
||||
})
|
||||
.filter(isDefined)
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
|
||||
export const getSelectedRoomsAvailabilityEnterDetails = cache(
|
||||
async function getMemoizedSelectedRoomsAvailability(
|
||||
input: RoomsAvailabilityExtendedInputSchema
|
||||
|
||||
Reference in New Issue
Block a user