diff --git a/src/views/components/common/SwitchButton.tsx b/src/views/components/common/SwitchButton.tsx index 5252e092..ab8b4d16 100644 --- a/src/views/components/common/SwitchButton.tsx +++ b/src/views/components/common/SwitchButton.tsx @@ -6,7 +6,16 @@ type ToggleSwitchProps = { onChange?: (checked: boolean) => void; }; -const SwitchButton: React.FC = ({ isChecked = true, onChange }) => { +/** + * A custom switch button component. + * + * @component + * @param {Object} props - The component props. + * @param {boolean} [props.isChecked=true] - The initial checked state of the switch button. + * @param {Function} props.onChange - The callback function to be called when the switch button is toggled. + * @returns {JSX.Element} The rendered SwitchButton component. + */ +const SwitchButton = ({ isChecked = true, onChange }: ToggleSwitchProps): JSX.Element => { const [enabled, setEnabled] = useState(isChecked); useEffect(() => { @@ -16,7 +25,7 @@ const SwitchButton: React.FC = ({ isChecked = true, onChange const handleChange = (checked: boolean) => { setEnabled(checked); if (onChange) { - onChange; + onChange(checked); } }; @@ -24,11 +33,11 @@ const SwitchButton: React.FC = ({ isChecked = true, onChange