import { Check, Star } from '@mui/icons-material' import { Box, Card, Chip, Divider, Radio, Typography } from '@mui/joy' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { useNotification } from '../service/NotificationProvider' import { GetSubscriptionSession } from '../utils/Fetcher' import AppModal from './common/AppModal' import ModalActions from './common/ModalActions' const SubscriptionModal = ({ onClose, open }) => { const { t } = useTranslation('settings') const [selectedPlan, setSelectedPlan] = useState('yearly') const [isLoading, setIsLoading] = useState(false) const { showError } = useNotification() const plans = { yearly: { price: '$39.00', period: 'year', total: '$39.00/year', // savings: 'Save $20.88', // popular: true, }, // monthly: { // price: '$4.99', // period: 'month', // total: '$4.99/month', // savings: null, // }, } const features = [ 'Task notifications and reminders', 'Rich text descriptions with images uploads', 'Thing-based task triggers', 'API tokens for integrations', 'Image uploads in descriptions', 'Advanced task automation', // 'Unlimited task history', // 'Unlimited things history', ] const handleSubscribe = async () => { setIsLoading(true) try { // Call the backend with the selected plan const response = await GetSubscriptionSession() if (!response.ok) { throw new Error(t('subscription.sessionFailed')) } const data = await response.json() // Redirect to Stripe if (data.sessionURL) { window.location.href = data.sessionURL } else { throw new Error('No session URL received') } } catch (error) { console.error('Subscription error:', error) showError({ title: t('subscription.errorTitle'), message: t('subscription.errorMessage'), }) } finally { setIsLoading(false) } } return ( } > {/* Features List */} What's included: {features.map((feature, index) => ( {feature} ))} {/* Plan Selection */} {Object.entries(plans).map(([key, plan]) => ( setSelectedPlan(key)} sx={{ width: '100%', minHeight: 48, maxHeight: 64, cursor: 'pointer', transition: 'all 0.2s', mb: 0.2, display: 'flex', alignItems: 'center', justifyContent: 'space-between', px: 2.5, py: 1.2, position: 'relative', overflow: 'visible', }} > setSelectedPlan(key)} value={key} name='subscription-plan' color='primary' sx={{ mr: 1 }} /> {key.charAt(0).toUpperCase() + key.slice(1)} {plan.price} {' '} / {plan.period} {plan.popular && ( } sx={{ fontWeight: 600, fontSize: 12, px: 1, py: 0.1, boxShadow: 2, mt: 0.8, }} > Most Popular )} {plan.savings && ( {plan.savings} )} ))} {/* Footer */} {t('subscription.cancelAnytime')} ) } export default SubscriptionModal