import { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { Subscription } from '../../../../../../types/subscription/dashboard/subscription' import { ActiveSubscription } from './states/active/active' import { CanceledSubscription } from './states/canceled' import { ExpiredSubscription } from './states/expired' import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context' function PastDueSubscriptionAlert({ subscription, }: { subscription: Subscription }) { const { t } = useTranslation() return ( <>
{t('account_has_past_due_invoice_change_plan_warning')}{' '} {t('view_your_invoices')}
) } function PersonalSubscriptionStates({ subscription, }: { subscription: Subscription }) { const { t } = useTranslation() const state = subscription?.recurly?.state 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, setRecurlyLoadError } = useSubscriptionDashboardContext() useEffect(() => { if (typeof window.recurly === 'undefined' || !window.recurly) { setRecurlyLoadError(true) } }) if (!personalSubscription) return null return ( <> {personalSubscription.recurly.account.has_past_due_invoice._ === 'true' && ( )} {recurlyLoadError && (
{t('payment_provider_unreachable_error')}
)}
) } export default PersonalSubscription