// src/renderer/components/BonusShopItem.tsx import React from 'react'; import { Card, CardContent, Box, Typography, Button, CardMedia, Divider, } from '@mui/material'; import CoinsDisplay from './CoinsDisplay'; export interface BonusShopItemProps { id: string; name: string; description?: string; level: number; effectValue: number; nextEffectValue?: number; // цена покупки и улучшения price?: number; upgradePrice: number; canUpgrade: boolean; mode?: 'buy' | 'upgrade'; isActive?: boolean; isPermanent?: boolean; imageUrl?: string; disabled?: boolean; onBuy?: () => void; onUpgrade?: () => void; onToggleActive?: () => void; } export const BonusShopItem: React.FC = ({ name, description, level, effectValue, nextEffectValue, price, upgradePrice, canUpgrade, mode, isActive = true, isPermanent = false, imageUrl, disabled, onBuy, onUpgrade, onToggleActive, }) => { const isBuyMode = mode === 'buy' || level === 0; const buttonText = isBuyMode ? 'Купить' : canUpgrade ? 'Улучшить' : 'Макс. уровень'; const displayedPrice = isBuyMode ? (price ?? upgradePrice) : upgradePrice; const buttonDisabled = disabled || (isBuyMode ? !onBuy || displayedPrice === undefined : !canUpgrade || !onUpgrade); const handlePrimaryClick = () => { if (buttonDisabled) return; if (isBuyMode && onBuy) onBuy(); else if (!isBuyMode && onUpgrade) onUpgrade(); }; return ( {/* Градиентный свет сверху — как в ShopItem */} {imageUrl && ( )} {/* Имя бонуса — градиентом как у ShopItem */} {name} Уровень: {level} {isPermanent && ' • Постоянный'} {description && ( {description} )} Текущий эффект:{' '} {effectValue.toLocaleString('ru-RU')} {typeof nextEffectValue === 'number' && !isBuyMode && canUpgrade && ( Следующий уровень:{' '} {nextEffectValue.toLocaleString('ru-RU')} )} {isActive ? 'Бонус активен' : 'Бонус не активен'} {isBuyMode ? 'Цена покупки' : 'Цена улучшения'} {displayedPrice !== undefined && ( )} {!isBuyMode && onToggleActive && ( {isActive ? 'Выключить' : 'Включить'} )} {/* Кнопка в стиле Registration / ShopItem */} ); }; export default BonusShopItem;