Merged in fix/LOY-430-filter-old-campaigns (pull request #3317)
fix(LOY-430): don't show inactive campaigns * fix(LOY-430): don't show inactive campaigns Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -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() {
|
||||
<Table.TBody>
|
||||
{hotelData.map((data) => {
|
||||
const { hotel } = data
|
||||
const hasCampaign = hotel.rewardNight.campaign.points
|
||||
const hasCampaign = hasActiveCampaign(hotel.rewardNight.campaign)
|
||||
return (
|
||||
<Table.TR key={hotel.id}>
|
||||
<Table.TD style={{ alignContent: "flex-start" }}>
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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<typeof hotelSchema>
|
||||
@@ -88,6 +89,8 @@ export type HotelInput = z.input<typeof hotelInputSchema>
|
||||
|
||||
export type RoomType = Pick<Room, "roomTypes" | "name">
|
||||
|
||||
export type RewardNight = z.output<typeof rewardNightSchema>
|
||||
|
||||
export interface HotelFilter {
|
||||
id: FacilityEnum
|
||||
name: string
|
||||
|
||||
Reference in New Issue
Block a user