@@ -13,10 +13,10 @@ import FieldFromConfig from 'sentry/components/forms/fieldFromConfig';
13
13
import Form from 'sentry/components/forms/form' ;
14
14
import { space } from 'sentry/styles/space' ;
15
15
import type { Organization } from 'sentry/types/organization' ;
16
- import { useMutation } from 'sentry/utils/queryClient' ;
17
- import useApi from 'sentry/utils/useApi' ;
16
+ import { fetchMutation , useMutation } from 'sentry/utils/queryClient' ;
18
17
19
18
interface ToggleConsolePlatformsModalProps extends ModalRenderProps {
19
+ onSuccess : ( ) => void ;
20
20
organization : Organization ;
21
21
}
22
22
@@ -25,14 +25,15 @@ export function ToggleConsolePlatformsModal({
25
25
Body,
26
26
closeModal,
27
27
organization,
28
+ onSuccess,
28
29
} : ToggleConsolePlatformsModalProps ) {
29
- const api = useApi ( ) ;
30
30
const { enabledConsolePlatforms = [ ] } = organization ;
31
31
32
32
const { isPending, mutate : updateConsolePlatforms } = useMutation ( {
33
33
mutationFn : ( platforms : Record < string , boolean > ) => {
34
- return api . requestPromise ( `/organizations/ ${ organization . slug } /` , {
34
+ return fetchMutation ( {
35
35
method : 'PUT' ,
36
+ url : `/organizations/${ organization . slug } /` ,
36
37
data : {
37
38
enabledConsolePlatforms : Object . keys ( platforms ) . reduce ( ( acc , key ) => {
38
39
if ( platforms [ key ] ) {
@@ -48,6 +49,7 @@ export function ToggleConsolePlatformsModal({
48
49
} ,
49
50
onSuccess : ( ) => {
50
51
addSuccessMessage ( `Console platforms updated for ${ organization . slug } ` ) ;
52
+ onSuccess ( ) ;
51
53
} ,
52
54
onError : ( ) => {
53
55
addErrorMessage ( `Failed to update console platforms for ${ organization . slug } ` ) ;
@@ -131,10 +133,16 @@ const StyledFieldFromConfig = styled(FieldFromConfig)`
131
133
132
134
export function openToggleConsolePlatformsModal ( {
133
135
organization,
136
+ onSuccess,
134
137
} : {
138
+ onSuccess : ( ) => void ;
135
139
organization : Organization ;
136
140
} ) {
137
141
return openModal ( deps => (
138
- < ToggleConsolePlatformsModal { ...deps } organization = { organization } />
142
+ < ToggleConsolePlatformsModal
143
+ { ...deps }
144
+ organization = { organization }
145
+ onSuccess = { onSuccess }
146
+ />
139
147
) ) ;
140
148
}
0 commit comments