Skip to content

Commit

Permalink
Merge pull request #20 from likhith-deriv/likhith/incorporate-review-…
Browse files Browse the repository at this point in the history
…comments

fix: minor bug fix
  • Loading branch information
yauheni-deriv committed May 12, 2023
2 parents 041cdad + e322a1b commit 42b2935
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ const PoiConfirmWithExampleFormContainer = ({
});

React.useEffect(() => {
const initializeFormValues = () => {
WS.wait('get_settings').then(() => {
const visible_settings = ['first_name', 'last_name', 'date_of_birth'];
const form_initial_values = filterObjProperties(account_settings, visible_settings);
if (form_initial_values.date_of_birth) {
form_initial_values.date_of_birth = toMoment(form_initial_values.date_of_birth).format(
'YYYY-MM-DD'
);
}
setRestState({
...rest_state,
changeable_fields: getChangeableFields(),
form_initial_values,
});
setIsLoading(false);
});
};

initializeFormValues();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [account_settings]);
Expand Down Expand Up @@ -101,22 +119,6 @@ const PoiConfirmWithExampleFormContainer = ({
return errors;
};

const initializeFormValues = () => {
WS.wait('get_settings').then(() => {
const visible_settings = ['first_name', 'last_name', 'date_of_birth'];
const form_initial_values = filterObjProperties(account_settings, visible_settings);
if (form_initial_values.date_of_birth) {
form_initial_values.date_of_birth = toMoment(form_initial_values.date_of_birth).format('YYYY-MM-DD');
}
setRestState({
...rest_state,
changeable_fields: getChangeableFields(),
form_initial_values,
});
setIsLoading(false);
});
};

const {
form_initial_values: { ...form_initial_values },
api_error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type TItemWrapper = {
type TRadioGroup = {
className?: string;
name: string;
onToggle: (e: ChangeEvent<HTMLInputElement>) => void;
onToggle: (e: React.MouseEvent<HTMLInputElement> & { target: { value: string } }) => void;
required?: boolean;
selected: string;
} & TItemWrapper;
Expand Down Expand Up @@ -37,8 +37,8 @@ const RadioGroup = ({
setSelectedOption(selected);
}, [selected]);

const onChange = (e: React.MouseEvent<HTMLInputElement>) => {
setSelectedOption(e?.target?.value);
const onChange = (e: React.MouseEvent<HTMLInputElement> & { target: { value: string } }) => {
setSelectedOption(e.target.value);
onToggle(e);
};

Expand Down

0 comments on commit 42b2935

Please sign in to comment.