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)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user