mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
612728d300
[web] Subscription dash reactivate button react migration GitOrigin-RevId: dde8dd1abb8979bdf90d71ea07e1336e9af491b3
31 lines
833 B
TypeScript
31 lines
833 B
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { postJSON } from '../../../../infrastructure/fetch-json'
|
|
import { reactivateSubscriptionUrl } from '../../data/subscription-url'
|
|
import { reload } from '../../../../shared/components/location'
|
|
import useAsync from '../../../../shared/hooks/use-async'
|
|
|
|
function ReactivateSubscription() {
|
|
const { t } = useTranslation()
|
|
const { isLoading, isSuccess, runAsync } = useAsync()
|
|
|
|
const handleReactivate = () => {
|
|
runAsync(postJSON(reactivateSubscriptionUrl)).catch(console.error)
|
|
}
|
|
|
|
if (isSuccess) {
|
|
reload()
|
|
}
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
className="btn btn-primary"
|
|
disabled={isLoading || isSuccess}
|
|
onClick={handleReactivate}
|
|
>
|
|
{t('reactivate_subscription')}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
export default ReactivateSubscription
|