chore(LOY-64): better organisation of reward types and data
This commit is contained in:
@@ -1,53 +1,55 @@
|
|||||||
|
import type { FC } from "react"
|
||||||
|
|
||||||
|
import { REWARD_IDS } from "@/constants/rewards"
|
||||||
|
|
||||||
import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name"
|
import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name"
|
||||||
import { isValidRewardId } from "@/utils/rewards"
|
import { isValidRewardId } from "@/utils/rewards"
|
||||||
|
|
||||||
import type { FC } from "react"
|
|
||||||
|
|
||||||
import { IconName, type IconProps } from "@/types/components/icon"
|
import { IconName, type IconProps } from "@/types/components/icon"
|
||||||
import { RewardId } from "@/types/enums/rewards"
|
import type { RewardId } from "@/types/components/myPages/rewards"
|
||||||
|
|
||||||
function getIconForRewardId(rewardId: RewardId): IconName {
|
function getIconForRewardId(rewardId: RewardId): IconName {
|
||||||
switch (rewardId) {
|
switch (rewardId) {
|
||||||
// Food & beverage
|
// Food & beverage
|
||||||
case RewardId.TenPercentFood:
|
case REWARD_IDS.TenPercentFood:
|
||||||
case RewardId.FifteenPercentFood:
|
case REWARD_IDS.FifteenPercentFood:
|
||||||
return IconName.CroissantCoffeeEgg
|
return IconName.CroissantCoffeeEgg
|
||||||
case RewardId.TwoForOneBreakfast:
|
case REWARD_IDS.TwoForOneBreakfast:
|
||||||
return IconName.CutleryTwo
|
return IconName.CutleryTwo
|
||||||
case RewardId.FreeBreakfast:
|
case REWARD_IDS.FreeBreakfast:
|
||||||
return IconName.CutleryOne
|
return IconName.CutleryOne
|
||||||
case RewardId.FreeKidsDrink:
|
case REWARD_IDS.FreeKidsDrink:
|
||||||
return IconName.KidsMocktail
|
return IconName.KidsMocktail
|
||||||
|
|
||||||
// Monetary vouchers
|
// Monetary vouchers
|
||||||
case RewardId.Bonus50SEK:
|
case REWARD_IDS.Bonus50SEK:
|
||||||
case RewardId.Bonus75SEK:
|
case REWARD_IDS.Bonus75SEK:
|
||||||
case RewardId.Bonus100SEK:
|
case REWARD_IDS.Bonus100SEK:
|
||||||
case RewardId.Bonus150SEK:
|
case REWARD_IDS.Bonus150SEK:
|
||||||
case RewardId.Bonus200SEK:
|
case REWARD_IDS.Bonus200SEK:
|
||||||
return IconName.Voucher
|
return IconName.Voucher
|
||||||
|
|
||||||
// Hotel perks
|
// Hotel perks
|
||||||
case RewardId.EarlyCheckin:
|
case REWARD_IDS.EarlyCheckin:
|
||||||
return IconName.HandKey
|
return IconName.HandKey
|
||||||
case RewardId.LateCheckout:
|
case REWARD_IDS.LateCheckout:
|
||||||
return IconName.HotelNight
|
return IconName.HotelNight
|
||||||
case RewardId.FreeUpgrade:
|
case REWARD_IDS.FreeUpgrade:
|
||||||
return IconName.MagicWand
|
return IconName.MagicWand
|
||||||
case RewardId.RoomGuarantee48H:
|
case REWARD_IDS.RoomGuarantee48H:
|
||||||
return IconName.Bed
|
return IconName.Bed
|
||||||
|
|
||||||
// Earnings
|
// Earnings
|
||||||
case RewardId.EarnRate25Percent:
|
case REWARD_IDS.EarnRate25Percent:
|
||||||
case RewardId.EarnRate50Percent:
|
case REWARD_IDS.EarnRate50Percent:
|
||||||
return IconName.MoneyHand
|
return IconName.MoneyHand
|
||||||
case RewardId.StayBoostForKids:
|
case REWARD_IDS.StayBoostForKids:
|
||||||
return IconName.Kids
|
return IconName.Kids
|
||||||
case RewardId.MemberRate:
|
case REWARD_IDS.MemberRate:
|
||||||
return IconName.Coin
|
return IconName.Coin
|
||||||
|
|
||||||
// Special
|
// Special
|
||||||
case RewardId.YearlyExclusiveGift:
|
case REWARD_IDS.YearlyExclusiveGift:
|
||||||
return IconName.GiftOpen
|
return IconName.GiftOpen
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const RewardId = {
|
export const REWARD_IDS = {
|
||||||
// Food & Beverage
|
// Food & Beverage
|
||||||
TenPercentFood: "tier_10_percent_food_tier",
|
TenPercentFood: "tier_10_percent_food_tier",
|
||||||
TwoForOneBreakfast: "tier_2_for_one_breakfast",
|
TwoForOneBreakfast: "tier_2_for_one_breakfast",
|
||||||
@@ -30,4 +30,10 @@ export const RewardId = {
|
|||||||
YearlyExclusiveGift: "tier_yearly_exclusive_gift",
|
YearlyExclusiveGift: "tier_yearly_exclusive_gift",
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type RewardId = (typeof RewardId)[keyof typeof RewardId]
|
export const RESTAURANT_REWARD_IDS = [
|
||||||
|
REWARD_IDS.TenPercentFood,
|
||||||
|
REWARD_IDS.TwoForOneBreakfast,
|
||||||
|
REWARD_IDS.FifteenPercentFood,
|
||||||
|
REWARD_IDS.FreeKidsDrink,
|
||||||
|
REWARD_IDS.FreeBreakfast,
|
||||||
|
] as const
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
|
import { RESTAURANT_REWARD_IDS, REWARD_IDS } from "@/constants/rewards"
|
||||||
|
|
||||||
import type { IconProps } from "@/types/components/icon"
|
import type { IconProps } from "@/types/components/icon"
|
||||||
|
|
||||||
export interface RewardIconProps extends IconProps {
|
export interface RewardIconProps extends IconProps {
|
||||||
rewardId: string
|
rewardId: string
|
||||||
size?: "small" | "medium" | "large"
|
size?: "small" | "medium" | "large"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type RewardId = (typeof REWARD_IDS)[keyof typeof REWARD_IDS]
|
||||||
|
|
||||||
|
export type RestaurantRewardId = (typeof RESTAURANT_REWARD_IDS)[number]
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
import { RewardId } from "@/types/enums/rewards"
|
import { RESTAURANT_REWARD_IDS, REWARD_IDS } from "@/constants/rewards"
|
||||||
|
|
||||||
|
import type {
|
||||||
|
RestaurantRewardId,
|
||||||
|
RewardId,
|
||||||
|
} from "@/types/components/myPages/rewards"
|
||||||
import type { Reward } from "@/server/routers/contentstack/reward/output"
|
import type { Reward } from "@/server/routers/contentstack/reward/output"
|
||||||
|
|
||||||
export function isValidRewardId(id: string): id is RewardId {
|
export function isValidRewardId(id: string): id is RewardId {
|
||||||
return Object.values<string>(RewardId).includes(id)
|
return Object.values<string>(REWARD_IDS).includes(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RESTAURANT_REWARD_IDS = [
|
|
||||||
RewardId.TenPercentFood,
|
|
||||||
RewardId.TwoForOneBreakfast,
|
|
||||||
RewardId.FifteenPercentFood,
|
|
||||||
RewardId.FreeKidsDrink,
|
|
||||||
RewardId.FreeBreakfast,
|
|
||||||
] as const
|
|
||||||
|
|
||||||
export type RestaurantRewardId = (typeof RESTAURANT_REWARD_IDS)[number]
|
|
||||||
|
|
||||||
export function isRestaurantReward(
|
export function isRestaurantReward(
|
||||||
rewardId: string
|
rewardId: string
|
||||||
): rewardId is RestaurantRewardId {
|
): rewardId is RestaurantRewardId {
|
||||||
@@ -40,4 +35,4 @@ export function isOnSiteTierReward(reward: Reward): boolean {
|
|||||||
|
|
||||||
export function isRestaurantOnSiteTierReward(reward: Reward): boolean {
|
export function isRestaurantOnSiteTierReward(reward: Reward): boolean {
|
||||||
return isOnSiteTierReward(reward) && isRestaurantReward(reward.reward_id)
|
return isOnSiteTierReward(reward) && isRestaurantReward(reward.reward_id)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user