File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
internal/webui/src/pages/SourcesPage/components/SourcesGrid/components Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change 1- import { useEffect , useState } from "react" ;
21import { Switch } from "@mui/material" ;
32import { Source } from "types/Source/Source" ;
43import { useEditSourceEnable } from "queries/Source" ;
@@ -9,23 +8,16 @@ type EnabledSourceSwitchProps = {
98} ;
109
1110export const EnabledSourceSwitch = ( { source } : EnabledSourceSwitchProps ) => {
12- const [ checked , setChecked ] = useState ( source . IsEnabled ) ;
13-
1411 const editEnabled = useEditSourceEnable ( ) ;
15- const { status } = editEnabled ;
1612
1713 const handleChange = ( _e : any , value : boolean ) => {
18- setChecked ( value ) ;
1914 editEnabled . mutate ( {
2015 ...source ,
2116 IsEnabled : value ,
2217 } ) ;
2318 } ;
24- useEffect ( ( ) => {
25- if ( status === "error" ) {
26- setChecked ( ( prev ) => ! prev ) ;
27- }
28- } , [ status ] ) ;
19+
20+ const checked = editEnabled . isPending ? ! source . IsEnabled : source . IsEnabled ;
2921
3022 return (
3123 < Switch
You can’t perform that action at this time.
0 commit comments