File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
site/src/pages/OrganizationSettingsPage Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change
1
+ import { getErrorMessage } from "api/errors" ;
1
2
import {
2
3
deleteOrganization ,
3
4
updateOrganization ,
4
5
} from "api/queries/organizations" ;
5
6
import { EmptyState } from "components/EmptyState/EmptyState" ;
6
7
import { displaySuccess } from "components/GlobalSnackbar/utils" ;
8
+ import { displayError } from "components/GlobalSnackbar/utils" ;
7
9
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout" ;
8
10
import type { FC } from "react" ;
9
11
import { useMutation , useQueryClient } from "react-query" ;
@@ -42,10 +44,19 @@ const OrganizationSettingsPage: FC = () => {
42
44
navigate ( `/organizations/${ updatedOrganization . name } /settings` ) ;
43
45
displaySuccess ( "Organization settings updated." ) ;
44
46
} }
45
- onDeleteOrganization = { ( ) => {
46
- deleteOrganizationMutation . mutate ( organization . id ) ;
47
- displaySuccess ( "Organization deleted." ) ;
48
- navigate ( "/organizations" ) ;
47
+ onDeleteOrganization = { async ( ) => {
48
+ try {
49
+ await deleteOrganizationMutation . mutateAsync ( organization . id ) ;
50
+ displaySuccess ( `Organization ${ organization . name } deleted` ) ;
51
+ navigate ( "/organizations" ) ;
52
+ } catch ( error ) {
53
+ displayError (
54
+ getErrorMessage (
55
+ error ,
56
+ `Failed to delete organization: ${ organization . name } ` ,
57
+ ) ,
58
+ ) ;
59
+ }
49
60
} }
50
61
/>
51
62
) ;
Original file line number Diff line number Diff line change @@ -146,7 +146,10 @@ export const OrganizationSettingsPageView: FC<
146
146
147
147
< DeleteDialog
148
148
isOpen = { isDeleting }
149
- onConfirm = { onDeleteOrganization }
149
+ onConfirm = { async ( ) => {
150
+ await onDeleteOrganization ( ) ;
151
+ setIsDeleting ( false ) ;
152
+ } }
150
153
onCancel = { ( ) => setIsDeleting ( false ) }
151
154
entity = "organization"
152
155
name = { organization . name }
You can’t perform that action at this time.
0 commit comments