@@ -22,7 +22,7 @@ import { SchemaOrganizationRole } from '@/integrations/api/api.gen';
2222import { safeParse } from '@/lib/string/safeParse' ;
2323import { zodResolver } from '@hookform/resolvers/zod' ;
2424import { Editor } from '@monaco-editor/react' ;
25- import { useSuspenseQuery } from '@tanstack/react-query' ;
25+ import { useQueryClient , useSuspenseQuery } from '@tanstack/react-query' ;
2626import { useCallback , useState } from 'react' ;
2727import { useForm } from 'react-hook-form' ;
2828import { toast } from 'sonner' ;
@@ -37,6 +37,7 @@ export function EditOrganizationRoleModal({
3737 isModalOpen : boolean ;
3838 closeModal : ( madeChanges : boolean ) => void ;
3939} ) {
40+ const queryClient = useQueryClient ( ) ;
4041 const { data : roleInfo } = useSuspenseQuery (
4142 getOrganizationRoleInfoQueryOptions ( { roleId : data . id , organizationId : data . organizationId } ) ,
4243 ) ;
@@ -52,8 +53,8 @@ export function EditOrganizationRoleModal({
5253 resolver : zodResolver ( OrganizationRoleOverviewSchema ) ,
5354 defaultValues : {
5455 name : data . roleName ,
55- update : roleInfo ? .organization . update || false ,
56- delete : roleInfo ? .organization . delete || false ,
56+ update : roleInfo . organization . update || false ,
57+ delete : roleInfo . organization . delete || false ,
5758 } ,
5859 } ) ;
5960
@@ -120,9 +121,12 @@ export function EditOrganizationRoleModal({
120121 updatedRoleInfo : updatedFormData ,
121122 } ,
122123 {
123- onSuccess : ( ) => {
124+ onSuccess : async ( ) => {
124125 toast . success ( 'Role updated successfully!' ) ;
125- closeModal ( true ) ;
126+ await queryClient . invalidateQueries ( {
127+ queryKey : [ data . organizationId , 'roles' , data . id ] ,
128+ } ) ;
129+ closeModal ( false ) ;
126130 form . reset ( ) ;
127131 } ,
128132 onError : ( error : Error | unknown ) => {
@@ -144,6 +148,7 @@ export function EditOrganizationRoleModal({
144148 data . organizationId ,
145149 form ,
146150 isValidJSON ,
151+ queryClient ,
147152 roleInfo ,
148153 update ,
149154 updatedPermissions ,
0 commit comments