Files
web/apps/scandic-web/components/Blocks/DynamicContent/RewardNights/util.ts
Matilda Landström 5770147af4 Merged in feat/LOY-501-table-sorting (pull request #3321)
feat(LOY-501): add sorting to Reward Night Table

* feat(LOY-501): add sorting using Tanstack Table


Approved-by: Chuma Mcphoy (We Ahead)
2025-12-11 14:08:01 +00:00

29 lines
722 B
TypeScript

import type { RewardNight } from "@scandic-hotels/trpc/types/hotel"
export interface HotelData {
url: string
name: string
city: string
country: string
rewardNight: RewardNight
}
export function formatDate(date?: string) {
return new Date(date ?? new Date()).toISOString().split("T")[0]
}
export function formatPoints(number: number) {
const format = new Intl.NumberFormat("fr-FR")
return format.format(number).replace(/\u202F/g, " ")
}
export function hasActiveCampaign(
campaign: HotelData["rewardNight"]["campaign"]
) {
return campaign.points && formatDate(campaign.end) >= formatDate()
}
export function nameToSort(name: string) {
return name.toLowerCase().replaceAll("scandic", "").trim()
}