File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
apps/admin/core/components/common Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,11 @@ export function ControllerSwitch<T extends FieldValues>(props: Props<T>) {
2626 < Controller
2727 control = { control }
2828 name = { name as FieldPath < T > }
29- render = { ( { field : { value, onChange } } ) => (
30- < ToggleSwitch
31- value = { Boolean ( parseInt ( value ) ) }
32- onChange = { ( ) => ( parseInt ( value ) ? onChange ( "0" ) : onChange ( "1" ) ) }
33- size = "sm"
34- />
35- ) }
29+ render = { ( { field : { value, onChange } } ) => {
30+ const parsedValue = Number . parseInt ( typeof value === "string" ? value : String ( value ?? "0" ) , 10 ) ;
31+ const isOn = ! Number . isNaN ( parsedValue ) && parsedValue !== 0 ;
32+ return < ToggleSwitch value = { isOn } onChange = { ( ) => onChange ( isOn ? "0" : "1" ) } size = "sm" /> ;
33+ } }
3634 />
3735 </ div >
3836 </ div >
You can’t perform that action at this time.
0 commit comments