Skip to content

Commit 4645356

Browse files
[WEB-5657] chore: synchronization configuration for multiple providers in authentication adapter #8409
1 parent c2ce21e commit 4645356

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

apps/admin/core/components/common/controller-switch.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)