Skip to content

Commit

Permalink
Refactor/form fields (deriv-com#24)
Browse files Browse the repository at this point in the history
* fix: add name prop to date of birth custom component

* fix: test cases

* refactor: update props from formik for date custom fields component
  • Loading branch information
shahzaib-deriv authored May 16, 2023
1 parent 7c02502 commit e015569
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/account/src/Components/forms/form-fields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ import { toMoment } from '@deriv/shared';

export const DateOfBirthField = ({ name, portal_id, ...rest }) => (
<Field name={name}>
{({ field: { value }, form: { setFieldValue, errors, touched, setTouched } }) => (
{({ field: { value }, form: { setFieldValue, errors, touched, setFieldTouched } }) => (
<DateOfBirthPicker
error={touched.date_of_birth && errors.date_of_birth}
name={name}
onBlur={() =>
setTouched({
date_of_birth: true,
})
}
onBlur={() => setFieldTouched(name)}
onChange={({ target }) =>
setFieldValue(
'date_of_birth',
target?.value ? toMoment(target.value).format('YYYY-MM-DD') : '',
true
)
setFieldValue(name, target?.value ? toMoment(target.value).format('YYYY-MM-DD') : '', true)
}
value={value}
portal_id={portal_id}
Expand Down

0 comments on commit e015569

Please sign in to comment.