feat(LOY-501): add sorting to Reward Night Table * feat(LOY-501): add sorting using Tanstack Table Approved-by: Chuma Mcphoy (We Ahead)
29 lines
722 B
TypeScript
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()
|
|
}
|