Feat/LOY-430 reward nights * chore(LOY-430): add reward nights request and dynamic content * chore(LOY-430): fix Reward Night component * Refactor: use existing endpoint and add rewardNight data to that response instead Approved-by: Linus Flood
34 lines
713 B
TypeScript
34 lines
713 B
TypeScript
import { env } from "@/env/server"
|
|
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
import type { WarmupFunction, WarmupResult } from "."
|
|
|
|
export const warmupHotelData =
|
|
(lang: Lang): WarmupFunction =>
|
|
async (): Promise<WarmupResult> => {
|
|
if (!env.ENABLE_WARMUP_HOTEL) {
|
|
return {
|
|
status: "skipped",
|
|
}
|
|
}
|
|
|
|
try {
|
|
const caller = await serverClient()
|
|
await caller.hotel.hotels.getAllHotelData({
|
|
lang,
|
|
warmup: true,
|
|
})
|
|
} catch (error) {
|
|
return {
|
|
status: "error",
|
|
error: error as Error,
|
|
}
|
|
}
|
|
|
|
return {
|
|
status: "completed",
|
|
}
|
|
}
|