import { Lang } from "@scandic-hotels/common/constants/language" import { isCityLocation } from "../../../types/locations" import { getHotelIdsByCityId } from "./getHotelIdsByCityId" import { getLocationsByCountries } from "./getLocationsByCountries" export async function getCityByCityIdentifier({ cityIdentifier, lang, serviceToken, }: { cityIdentifier: string lang: Lang serviceToken: string }) { const locations = await getLocationsByCountries({ lang, citiesByCountry: null, serviceToken, }) if (!locations || locations.length === 0) { return null } const city = locations .filter(isCityLocation) .find((loc) => loc.cityIdentifier === cityIdentifier) return city ?? null } export async function getHotelIdsByCityIdentifier( cityIdentifier: string, serviceToken: string ) { const city = await getCityByCityIdentifier({ cityIdentifier, lang: Lang.en, serviceToken, }) if (!city) { return [] } const hotelIds = await getHotelIdsByCityId({ cityId: city.id, serviceToken, }) return hotelIds }