mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 02:26:45 -05:00
1213709578
[web] migrate frontend logging to debugConsole GitOrigin-RevId: b03ff9030b03fff059738d2270bc4b4912e79f16
39 lines
1.1 KiB
TypeScript
39 lines
1.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'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
function ReactivateSubscription() {
|
|
const { t } = useTranslation()
|
|
const { isLoading, isSuccess, runAsync } = useAsync()
|
|
const location = useLocation()
|
|
|
|
const handleReactivate = () => {
|
|
runAsync(postJSON(reactivateSubscriptionUrl)).catch(debugConsole.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
|