@@ -21,6 +21,7 @@ import { ConfirmationDialog, DeleteDialog } from '../Dialogs'
21
21
import { ServerErrors } from '../ServerError'
22
22
import { DeleteComponentProps } from './types'
23
23
import { ToastManager , ToastVariantType } from '@Shared/Services'
24
+ import { showError } from '@Common/Helper'
24
25
25
26
const DeleteComponent = ( {
26
27
setDeleting,
@@ -36,11 +37,13 @@ const DeleteComponent = ({
36
37
configuration = '' ,
37
38
closeCustomComponent,
38
39
} : DeleteComponentProps ) => {
40
+ const [ isDeleting , setIsDeleting ] = useState ( false )
39
41
const [ showCannotDeleteDialogModal , setCannotDeleteDialogModal ] = useState ( false )
40
42
const { push } = useHistory ( )
41
43
42
44
async function handleDelete ( ) {
43
45
setDeleting ( true )
46
+ setIsDeleting ( true )
44
47
try {
45
48
await deleteComponent ( payload )
46
49
ToastManager . showToast ( {
@@ -59,9 +62,12 @@ const DeleteComponent = ({
59
62
} catch ( serverError ) {
60
63
if ( serverError instanceof ServerErrors && serverError . code === 500 ) {
61
64
setCannotDeleteDialogModal ( true )
65
+ } else {
66
+ showError ( serverError )
62
67
}
63
68
} finally {
64
69
setDeleting ( false )
70
+ setIsDeleting ( false )
65
71
}
66
72
}
67
73
@@ -92,6 +98,7 @@ const DeleteComponent = ({
92
98
delete = { handleDelete }
93
99
closeDelete = { ( ) => toggleConfirmation ( false ) }
94
100
dataTestId = "delete-dialog"
101
+ apiCallInProgress = { isDeleting }
95
102
>
96
103
< DeleteDialog . Description >
97
104
< p > Are you sure you want to delete this { configuration || component } ? </ p >
0 commit comments