mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 09:54:02 -05:00
f375362894
* Always use mockable location methods * Add eslint rules for window.location calls/assignment * Add useLocation hook * Update tests GitOrigin-RevId: eafb846db89f884a7a9a8570cce7745be605152c
32 lines
879 B
TypeScript
32 lines
879 B
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'
|
|
|
|
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()
|
|
}
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
className="btn btn-primary"
|
|
disabled={isLoading || isSuccess}
|
|
onClick={handleReactivate}
|
|
>
|
|
{t('reactivate_subscription')}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
export default ReactivateSubscription
|