Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/accounts/DeleteFreeAccountOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const DeleteFreeAccountOverlay: FC = () => {
useContext(DeleteFreeAccountContext)
const {user, account} = useSelector(selectCurrentIdentity)
const org = useSelector(selectCurrentOrg)
const [isLoading, setIsLoading] = useState(false)

const handleClose = () => {
const payload = {
Expand All @@ -63,6 +64,8 @@ export const DeleteFreeAccountOverlay: FC = () => {
}, [hasAgreedToTerms, reason])

const handleDeleteAccount = async () => {
setIsLoading(true)

const payload = {
org: org.id,
tier: account.type,
Expand All @@ -83,6 +86,8 @@ export const DeleteFreeAccountOverlay: FC = () => {
window.location.href = getRedirectLocation()
} catch {
dispatch(notify(accountSelfDeletionFailed()))
} finally {
setIsLoading(false)
}
}

Expand Down Expand Up @@ -144,9 +149,15 @@ export const DeleteFreeAccountOverlay: FC = () => {
color={ComponentColor.Danger}
text="Delete Account"
testID="delete-free-account--button"
status={
isFormValid ? ComponentStatus.Default : ComponentStatus.Disabled
}
status={(() => {
if (isLoading) {
return ComponentStatus.Loading
} else if (!isFormValid) {
return ComponentStatus.Disabled
} else {
return ComponentStatus.Default
}
})()}
onClick={handleDeleteAccount}
/>
</Overlay.Footer>
Expand Down
10 changes: 9 additions & 1 deletion src/operator/account/DeleteAccountOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {FC, useContext} from 'react'
import React, {FC, useContext, useState} from 'react'
import {
Overlay,
Gradients,
Expand All @@ -7,6 +7,7 @@ import {
IconFont,
ButtonBase,
ButtonShape,
ComponentStatus,
} from '@influxdata/clockface'
import {AccountContext} from 'src/operator/context/account'

Expand All @@ -18,13 +19,17 @@ const DeleteAccountOverlay: FC = () => {
setDeleteOverlayVisible,
deleteOverlayVisible,
} = useContext(AccountContext)
const [isLoading, setIsLoading] = useState(false)

const deleteAccount = () => {
if (account?.deletable) {
setIsLoading(true)
try {
handleDeleteAccount()
} catch (e) {
setDeleteOverlayVisible(false)
} finally {
setIsLoading(false)
}
}
}
Expand Down Expand Up @@ -63,6 +68,9 @@ const DeleteAccountOverlay: FC = () => {
color={ComponentColor.Danger}
shape={ButtonShape.Default}
onClick={deleteAccount}
status={
isLoading ? ComponentStatus.Loading : ComponentStatus.Default
}
testID="delete-account--confirmation-button"
>
I understand, delete account.
Expand Down