import React, { useState } from 'react' import { PricingCardProps } from '@/app/types' import Button from '@/components/ui/Button' import showToast from '@/components/ui/Toast' import useUserStore from '@/app/store/userStore' const PricingCard: React.FC = ({ plan, price, features, isPopular, isActive, onPlanChange, }) => { const [isLoading, setIsLoading] = useState(false) const { user, setUser } = useUserStore() const handlePlanChange = async () => { try { setIsLoading(true) console.log('Changing plan to:', plan) // const response = await changePlan(plan) -- тут обработка данных запроса на смену плана // обновляем данные в сторе if (user) { setUser({ ...user, account_type: plan, }) } // обновляем данные на странице if (onPlanChange) { onPlanChange() } showToast({ type: 'success', duration: 1000, message: `Тариф успешно изменен на ${plan.toUpperCase()}!`, }) } catch (error) { console.error('Error changing plan:', error) showToast({ type: 'error', message: 'Не удалось изменить тариф. Попробуйте позже.', }) } finally { setIsLoading(false) } } return (
{isPopular && (
Популярный выбор
)} {isActive && (
Активный план
)}

{plan}

{price}₸ {price > 0 && / месяц}
    {features.map((feature, index) => (
  • {feature}
  • ))}
) } export default PricingCard