feat(LOY-64): add ActiveRedeemedBadge UI for on site tier rewards
This commit is contained in:
@@ -1,5 +1,43 @@
|
||||
import { RewardId } from "@/types/enums/rewards"
|
||||
import type { Reward } from "@/server/routers/contentstack/reward/output"
|
||||
|
||||
export function isValidRewardId(id: string): id is RewardId {
|
||||
return Object.values<string>(RewardId).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(
|
||||
rewardId: string
|
||||
): rewardId is RestaurantRewardId {
|
||||
return RESTAURANT_REWARD_IDS.some((id) => id === rewardId)
|
||||
}
|
||||
|
||||
export function redeemLocationIsOnSite(
|
||||
location: Reward["redeemLocation"]
|
||||
): location is "On-site" {
|
||||
return location === "On-site"
|
||||
}
|
||||
|
||||
export function isTierType(type: Reward["rewardType"]): type is "Tier" {
|
||||
return type === "Tier"
|
||||
}
|
||||
|
||||
export function isOnSiteTierReward(reward: Reward): boolean {
|
||||
return (
|
||||
redeemLocationIsOnSite(reward.redeemLocation) &&
|
||||
isTierType(reward.rewardType)
|
||||
)
|
||||
}
|
||||
|
||||
export function isRestaurantOnSiteTierReward(reward: Reward): boolean {
|
||||
return isOnSiteTierReward(reward) && isRestaurantReward(reward.reward_id)
|
||||
}
|
||||
Reference in New Issue
Block a user