@@ -77,7 +77,7 @@ export const EditResource = ({ reload, data }: any) => {
7777 } ,
7878 } ) ;
7979 if ( variables . isResetSchema ) {
80- schemaMutate ( {
80+ schemaMutation . mutate ( {
8181 resourceId : resourceId ,
8282 } ) ;
8383 }
@@ -105,23 +105,19 @@ export const EditResource = ({ reload, data }: any) => {
105105 }
106106 ` ) ;
107107
108- const { mutate : schemaMutate , isLoading : isSchemaLoading } = useMutation (
108+ const schemaMutation = useMutation (
109109 ( data : { resourceId : string } ) => GraphQL ( resetSchema , data ) ,
110110 {
111111 onSuccess : ( ) => {
112- refetch ( ) ;
112+ schemaQuery . refetch ( ) ;
113113 } ,
114114 onError : ( err : any ) => {
115115 console . log ( 'Error ::: ' , err ) ;
116116 } ,
117117 }
118118 ) ;
119119
120- const {
121- data : payload ,
122- refetch,
123- isLoading : isPending ,
124- } = useQuery < any > ( [ `fetch_schema_${ params . id } ` ] , ( ) =>
120+ const schemaQuery = useQuery < any > ( [ `fetch_schema_${ params . id } ` ] , ( ) =>
125121 GraphQL ( fetchSchema , { datasetId : params . id } )
126122 ) ;
127123
@@ -143,7 +139,7 @@ export const EditResource = ({ reload, data }: any) => {
143139 ( data : { input : SchemaUpdateInput } ) => GraphQL ( updateSchema , data ) ,
144140 {
145141 onSuccess : ( ) => {
146- refetch ( ) ;
142+ schemaQuery . refetch ( ) ;
147143 toast ( 'Schema Updated Successfully' , {
148144 action : {
149145 label : 'Dismiss' ,
@@ -169,7 +165,7 @@ export const EditResource = ({ reload, data }: any) => {
169165 onClick : ( ) => { } ,
170166 } ,
171167 } ) ;
172- refetch ( ) ;
168+ schemaQuery . refetch ( ) ;
173169 reload ( ) ;
174170 } ,
175171 onError : ( err : any ) => {
@@ -469,7 +465,7 @@ export const EditResource = ({ reload, data }: any) => {
469465 kind = "tertiary"
470466 variant = "basic"
471467 onClick = { ( ) =>
472- schemaMutate ( {
468+ schemaMutation . mutate ( {
473469 resourceId : resourceId ,
474470 } )
475471 }
@@ -484,15 +480,16 @@ export const EditResource = ({ reload, data }: any) => {
484480 The Field settings apply to the Resource on a master level and can not
485481 be changed in Access Models.
486482 </ Text >
487- { isPending || isSchemaLoading ? (
483+ { schemaQuery . isLoading || schemaMutation . isLoading ? (
488484 < div className = " mt-8 flex justify-center" >
489485 < Spinner size = { 30 } />
490486 </ div >
491- ) : resourceId && payload ?. datasetResources ?. filter (
487+ ) : resourceId && schemaQuery . data ?. datasetResources ?. filter (
492488 ( item : any ) => item . id === resourceId ) . length > 0 ? (
493489 < ResourceSchema
494490 setSchema = { setSchema }
495- data = { payload ?. datasetResources ?. filter ( ( item : any ) => item . id === resourceId ) [ 0 ] ?. schema }
491+ data = { schemaQuery . data ?. datasetResources ?. filter (
492+ ( item : any ) => item . id === resourceId ) [ 0 ] ?. schema }
496493 />
497494 ) : (
498495 < div className = "my-8 flex justify-center" > Click on Reset Fields </ div >
0 commit comments