diff --git a/apps/scandic-web/components/Blocks/DynamicContent/RewardNights/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/RewardNights/index.tsx
index b755b6d7d..2a71cef4d 100644
--- a/apps/scandic-web/components/Blocks/DynamicContent/RewardNights/index.tsx
+++ b/apps/scandic-web/components/Blocks/DynamicContent/RewardNights/index.tsx
@@ -10,6 +10,8 @@ import { getIntl } from "@/i18n"
import styles from "./rewardNights.module.css"
+import type { RewardNight } from "@scandic-hotels/trpc/types/hotel"
+
export async function RewardNights() {
const intl = await getIntl()
const hotelData = await getAllHotelData()
@@ -41,7 +43,7 @@ export async function RewardNights() {
{hotelData.map((data) => {
const { hotel } = data
- const hasCampaign = hotel.rewardNight.campaign.points
+ const hasCampaign = hasActiveCampaign(hotel.rewardNight.campaign)
return (
@@ -117,6 +119,10 @@ function formatPoints(number: number) {
return format.format(number).replace(/\u202F/g, " ")
}
-function formatDate(date: string) {
- return new Date(date).toISOString().split("T")[0]
+function formatDate(date?: string) {
+ return new Date(date ?? Date.now()).toISOString().split("T")[0]
+}
+
+function hasActiveCampaign(campaign: RewardNight["campaign"]) {
+ return campaign.points && formatDate(campaign.end) >= formatDate()
}
diff --git a/packages/trpc/lib/types/hotel.ts b/packages/trpc/lib/types/hotel.ts
index e42b40621..f28913808 100644
--- a/packages/trpc/lib/types/hotel.ts
+++ b/packages/trpc/lib/types/hotel.ts
@@ -35,6 +35,7 @@ import type { locationSchema } from "../routers/hotels/schemas/hotel/location"
import type { parkingSchema } from "../routers/hotels/schemas/hotel/parking"
import type { pointOfInterestSchema } from "../routers/hotels/schemas/hotel/poi"
import type { ratingsSchema } from "../routers/hotels/schemas/hotel/rating"
+import type { rewardNightSchema } from "../routers/hotels/schemas/hotel/rewardNight"
import type { imageSchema } from "../routers/hotels/schemas/image"
export type HotelData = z.output
@@ -88,6 +89,8 @@ export type HotelInput = z.input
export type RoomType = Pick
+export type RewardNight = z.output
+
export interface HotelFilter {
id: FacilityEnum
name: string