import { FetchError, postJSON } from '@/infrastructure/fetch-json' import Notification from '@/shared/components/notification' import useAsync from '@/shared/hooks/use-async' import { debugConsole } from '@/utils/debugging' import getMeta from '@/utils/meta' import { Dispatch, SetStateAction, useCallback } from 'react' import { useTranslation } from 'react-i18next' import { InviteViewTypes } from './group-invite' export default function HasIndividualRecurlySubscription({ setView, }: { setView: Dispatch> }) { const { t } = useTranslation() const { runAsync, isLoading: isCancelling, isError, } = useAsync() const cancelPersonalSubscription = useCallback(() => { runAsync( postJSON('/user/subscription/cancel', { body: { _csrf: getMeta('ol-csrfToken'), }, }) ) .then(() => { setView('invite') }) .catch(debugConsole.error) }, [runAsync, setView]) return ( <> {isError && ( )}

{t('cancel_personal_subscription_first')}

  

) }