Fix(SW-1711)/(SW-2077): Export icons individually * fix(SW-1711): export icons individually Approved-by: Michael Zetterberg Approved-by: Erik Tiekstra
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import { REWARD_IDS } from "@/constants/rewards"
|
|
|
|
import { IconName } from "@/components/Icons/iconName"
|
|
import { IllustrationByIconName } from "@/components/Icons/IllustrationByIconName"
|
|
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)
|
|
}
|