fix: SW-2838 Use of city identifier instead of city name * fix: SW-2838 Updated selection to city identifier instead of city name Approved-by: Christian Andolf Approved-by: Linus Flood
25 lines
721 B
TypeScript
25 lines
721 B
TypeScript
import { getSearchTokens } from "./getSearchTokens"
|
|
|
|
import type { Location } from "@/types/trpc/routers/hotel/locations"
|
|
import type { AutoCompleteLocation } from "../schema"
|
|
|
|
export function mapLocationToAutoCompleteLocation(
|
|
location: (Location & { url?: string }) | null | undefined
|
|
): AutoCompleteLocation | null {
|
|
if (!location) return null
|
|
|
|
return {
|
|
id: location.id,
|
|
name: location.name,
|
|
type: location.type,
|
|
url: location.url,
|
|
searchTokens: getSearchTokens(location),
|
|
destination:
|
|
location.type === "hotels"
|
|
? location.relationships.city.name
|
|
: location.country,
|
|
cityIdentifier:
|
|
location.type === "cities" ? location.cityIdentifier : undefined,
|
|
}
|
|
}
|