Files
web/apps/scandic-web/components/Blocks/DynamicContent/Rewards/RewardIcon/data.ts
Anton Gunnarsson b52a3f5847 Merged in feat/sw-3145-move-iconbyiconname-to-design-system (pull request #2589)
Move icon components to design-system

* Move icon components to design-system


Approved-by: Hrishikesh Vaipurkar
2025-08-04 11:32:00 +00:00

73 lines
2.1 KiB
TypeScript

// import { REWARD_IDS } from "@scandic-hotels/trpc/types/rewards"
import { IconName } from "@scandic-hotels/design-system/Icons/iconName"
import { IllustrationByIconName } from "@scandic-hotels/design-system/Icons/IllustrationByIconName"
import { REWARD_IDS, type RewardId } from "@scandic-hotels/trpc/types/rewards"
import { isValidRewardId } from "@/utils/rewards"
import type { IconProps } from "@scandic-hotels/design-system/Icons"
import type { FC } from "react"
// import type { RewardId } from "@/types/components/myPages/rewards"
function getIconForRewardId(rewardId: RewardId): IconName {
switch (rewardId) {
// Food & beverage
case REWARD_IDS.TenPercentFood:
case REWARD_IDS.FifteenPercentFood:
return IconName.CroissantCoffeeEgg
case REWARD_IDS.TwoForOneBreakfast:
return IconName.CutleryTwo
case REWARD_IDS.FreeBreakfast:
return IconName.CutleryOne
case REWARD_IDS.FreeKidsDrink:
return IconName.KidsMocktail
// Monetary vouchers
case REWARD_IDS.Bonus50SEK:
case REWARD_IDS.Bonus75SEK:
case REWARD_IDS.Bonus100SEK:
case REWARD_IDS.Bonus150SEK:
case REWARD_IDS.Bonus200SEK:
return IconName.Voucher
// Hotel perks
case REWARD_IDS.EarlyCheckin:
return IconName.HandKey
case REWARD_IDS.LateCheckout:
return IconName.HotelNight
case REWARD_IDS.FreeUpgrade:
return IconName.MagicWand
case REWARD_IDS.RoomGuarantee48H:
return IconName.Bed
// Earnings
case REWARD_IDS.EarnRate25Percent:
case REWARD_IDS.EarnRate50Percent:
return IconName.MoneyHand
case REWARD_IDS.StayBoostForKids:
return IconName.Kids
case REWARD_IDS.MemberRate:
return IconName.Coin
// Special
case REWARD_IDS.YearlyExclusiveGift:
return IconName.GiftOpen
default: {
return IconName.GiftOpen
}
}
}
export function mapRewardToIcon(rewardId: string): FC<IconProps> | null {
if (!isValidRewardId(rewardId)) {
// TODO: Update once UX has decided on fallback icon.
return IllustrationByIconName(IconName.GiftOpen)
}
const iconName = getIconForRewardId(rewardId)
return IllustrationByIconName(iconName)
}