import { Trans, useTranslation } from 'react-i18next' import { RecurlySubscription } from '../../../../../../types/subscription/dashboard/subscription' import { ActiveSubscription } from './states/active/active' import { ActiveAiAddonSubscription } from './states/active/active-ai-addon' import { CanceledSubscription } from './states/canceled' import { ExpiredSubscription } from './states/expired' import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context' import PersonalSubscriptionRecurlySyncEmail from './personal-subscription-recurly-sync-email' import OLNotification from '@/features/ui/components/ol/ol-notification' import { AI_STANDALONE_PLAN_CODE, AI_STANDALONE_ANNUAL_PLAN_CODE, AI_ADD_ON_CODE, } from '../../data/add-on-codes' function PastDueSubscriptionAlert({ subscription, }: { subscription: RecurlySubscription }) { const { t } = useTranslation() return ( {t('account_has_past_due_invoice_change_plan_warning')}{' '} {t('view_your_invoices')} } /> ) } function PersonalSubscriptionStates({ subscription, }: { subscription: RecurlySubscription }) { const { t } = useTranslation() const state = subscription?.recurly.state const hasAiAddon = subscription?.addOns?.some( addOn => addOn.addOnCode === AI_ADD_ON_CODE ) const onAiStandalonePlan = [ AI_STANDALONE_PLAN_CODE, AI_STANDALONE_ANNUAL_PLAN_CODE, ].includes(subscription.planCode) const planHasAi = onAiStandalonePlan || hasAiAddon if (state === 'active' && planHasAi) { return } else if (state === 'active') { return } else if (state === 'canceled') { return } else if (state === 'expired') { return } else { return <>{t('problem_with_subscription_contact_us')} } } function PersonalSubscription() { const { t } = useTranslation() const { personalSubscription, recurlyLoadError } = useSubscriptionDashboardContext() if (!personalSubscription) return null if (!('recurly' in personalSubscription)) { return (

]} // eslint-disable-line react/jsx-key, jsx-a11y/anchor-has-content />

) } return ( <> {personalSubscription.recurly.account.has_past_due_invoice._ === 'true' && ( )} {recurlyLoadError && ( {t('payment_provider_unreachable_error')}} /> )}
) } export default PersonalSubscription