overleaf/services/web/frontend/js/features/subscription/components/dashboard/reactivate-subscription.tsx
Brian Gough d298a258e0 Merge pull request #13932 from overleaf/bg-managed-users-hide-reactivate-button
hide button to reactivate subscription for managed users

GitOrigin-RevId: 3632c5ffdee68eb5e0aed1479f3b7ffb45e3aa4a
2023-07-21 08:04:31 +00:00

38 lines
1 KiB
TypeScript

import { useTranslation } from 'react-i18next'
import { postJSON } from '../../../../infrastructure/fetch-json'
import { reactivateSubscriptionUrl } from '../../data/subscription-url'
import useAsync from '../../../../shared/hooks/use-async'
import { useLocation } from '../../../../shared/hooks/use-location'
import getMeta from '../../../../utils/meta'
function ReactivateSubscription() {
const { t } = useTranslation()
const { isLoading, isSuccess, runAsync } = useAsync()
const location = useLocation()
const handleReactivate = () => {
runAsync(postJSON(reactivateSubscriptionUrl)).catch(console.error)
}
if (isSuccess) {
location.reload()
}
// Don't show the button to reactivate the subscription for managed users
if (getMeta('ol-cannot-reactivate-subscription')) {
return null
}
return (
<button
type="button"
className="btn btn-primary"
disabled={isLoading || isSuccess}
onClick={handleReactivate}
>
{t('reactivate_subscription')}
</button>
)
}
export default ReactivateSubscription