TelegramPWA/src/components/common/GiftRarityBadge.tsx
2026-02-27 19:51:24 +01:00

39 lines
1005 B
TypeScript

import type { ApiStarGiftAttributeRarity } from '../../api/types';
import buildClassName from '../../util/buildClassName';
import { getGiftRarityTitle } from './helpers/gifts';
import useLang from '../../hooks/useLang';
import BadgeButton from './BadgeButton';
import styles from './GiftRarityBadge.module.scss';
type OwnProps = {
rarity: ApiStarGiftAttributeRarity;
shouldInvertRare?: boolean;
className?: string;
onClick?: NoneToVoidFunction;
};
const GiftRarityBadge = ({ rarity, shouldInvertRare, className, onClick }: OwnProps) => {
const lang = useLang();
return (
<BadgeButton
className={buildClassName(
styles.root,
rarity.type !== 'regular' && styles[rarity.type],
rarity.type !== 'regular' && styles.crafted,
shouldInvertRare && rarity.type !== 'regular' && styles.inverted,
className,
)}
onClick={onClick}
>
{getGiftRarityTitle(lang, rarity)}
</BadgeButton>
);
};
export default GiftRarityBadge;