From e322a1bf3db34b0ce51efe7aa23a2cb749407413 Mon Sep 17 00:00:00 2001 From: Likhith Kolayari Date: Fri, 12 May 2023 16:38:47 +0400 Subject: [PATCH] fix: minor bug fix --- ...oi-confirm-with-example-form-container.tsx | 34 ++++++++++--------- .../components/radio-group/radio-group.tsx | 6 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/account/src/Components/poi/poi-confirm-with-example-form-container/poi-confirm-with-example-form-container.tsx b/packages/account/src/Components/poi/poi-confirm-with-example-form-container/poi-confirm-with-example-form-container.tsx index 651f03e19722..2feffd3ec7d8 100644 --- a/packages/account/src/Components/poi/poi-confirm-with-example-form-container/poi-confirm-with-example-form-container.tsx +++ b/packages/account/src/Components/poi/poi-confirm-with-example-form-container/poi-confirm-with-example-form-container.tsx @@ -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]); @@ -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, diff --git a/packages/components/src/components/radio-group/radio-group.tsx b/packages/components/src/components/radio-group/radio-group.tsx index 678722f73312..d54ac1d30360 100644 --- a/packages/components/src/components/radio-group/radio-group.tsx +++ b/packages/components/src/components/radio-group/radio-group.tsx @@ -9,7 +9,7 @@ type TItemWrapper = { type TRadioGroup = { className?: string; name: string; - onToggle: (e: ChangeEvent) => void; + onToggle: (e: React.MouseEvent & { target: { value: string } }) => void; required?: boolean; selected: string; } & TItemWrapper; @@ -37,8 +37,8 @@ const RadioGroup = ({ setSelectedOption(selected); }, [selected]); - const onChange = (e: React.MouseEvent) => { - setSelectedOption(e?.target?.value); + const onChange = (e: React.MouseEvent & { target: { value: string } }) => { + setSelectedOption(e.target.value); onToggle(e); };