Skip to content

Commit

Permalink
remove unnessesary handleCheckboxChange function
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanMylyi committed Jul 29, 2024
1 parent f9a78a8 commit 0400bb3
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/containers/guest-home-page/login-form/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ interface LoginFormProps {
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void
handleChange: (
name: string
) => (e: React.ChangeEvent<HTMLInputElement>) => void
) => (
e:
| React.ChangeEvent<HTMLInputElement>
| { target: { name: string; value: string | boolean } }
) => void
handleBlur: (name: string) => (e: React.FocusEvent<HTMLInputElement>) => void
data: {
email: string
Expand Down Expand Up @@ -52,21 +56,6 @@ const LoginForm: React.FC<LoginFormProps> = ({
openModal({ component: <ForgotPassword /> })
}

const handleCheckboxChange = (
event: React.SyntheticEvent<Element, Event>,
checked: boolean
) => {
const target = event.target as HTMLInputElement
const changeEvent = {
...event,
target: {
...target,
value: checked.toString()
}
} as React.ChangeEvent<HTMLInputElement>
handleChange(target.name)(changeEvent)
}

return (
<Box component='form' onSubmit={handleSubmit} sx={styles.form}>
<AppTextField
Expand Down Expand Up @@ -98,12 +87,21 @@ const LoginForm: React.FC<LoginFormProps> = ({

<Box sx={styles.loginOptionsContainer}>
<FormControlLabel
control={<Checkbox checked={data.rememberMe} name='rememberMe' />}
control={
<Checkbox
checked={data.rememberMe}
name='rememberMe'
onChange={(e) =>
handleChange('rememberMe')({
...e,
target: { ...e.target, value: e.target.checked }
})
}
/>
}
label={t('login.rememberMe')}
labelPlacement='end'
onChange={handleCheckboxChange}
sx={styles.checkboxLabel}
value={data.rememberMe}
/>

<Typography
Expand Down

0 comments on commit 0400bb3

Please sign in to comment.