Skip to content

Commit 44206a2

Browse files
authored
fix(organisation): disable delete button when active subscription exists (#7809)
1 parent cbc295a commit 44206a2

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

frontend/web/components/pages/organisation-settings/tabs/general-tab/sections/DeleteOrganisation.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import { useHistory } from 'react-router-dom'
3+
import { planNames } from 'common/utils/utils'
34
import { Organisation } from 'common/types/responses'
45
import { useDeleteOrganisationWithToast } from 'components/pages/organisation-settings/hooks'
56
import ConfirmRemoveOrganisation from 'components/modals/ConfirmRemoveOrganisation'
@@ -37,6 +38,9 @@ export const DeleteOrganisation = ({
3738
'p-0',
3839
)
3940
}
41+
const isDeleteButtonDisabled =
42+
Utils.getPlanName(organisation.subscription?.plan ?? '') !==
43+
planNames.free && !organisation.subscription?.cancellation_date
4044

4145
return (
4246
<>
@@ -53,10 +57,18 @@ export const DeleteOrganisation = ({
5357
data-test='delete-org-btn'
5458
onClick={handleDelete}
5559
theme='danger'
56-
disabled={isLoading}
60+
disabled={isLoading || isDeleteButtonDisabled}
5761
>
5862
{isLoading ? 'Deleting...' : 'Delete Organisation'}
5963
</Button>
64+
{isDeleteButtonDisabled && (
65+
<div className='col-md-7'>
66+
<p className='text-danger'>
67+
You need to cancel your active subscriptions before deleting your
68+
organisation.
69+
</p>
70+
</div>
71+
)}
6072
</Row>
6173
</>
6274
)

0 commit comments

Comments
 (0)