diff --git a/packages/haring-react/src/Form/AddressFields/AddressFields.tsx b/packages/haring-react/src/Form/AddressFields/AddressFields.tsx index c6b95e2e..2fb0a2a0 100644 --- a/packages/haring-react/src/Form/AddressFields/AddressFields.tsx +++ b/packages/haring-react/src/Form/AddressFields/AddressFields.tsx @@ -88,7 +88,7 @@ export function AddressFields(props: IAddressFieldsProps): ReactElement { }, { error: errors?.postCode, - handleChange: (e: React.ChangeEvent) => { + onChange: (e: React.ChangeEvent) => { onChangeHandle('postCode', e.target.value); }, value: value?.postCode, diff --git a/packages/storybook-pages/src/Pages/StepperPage/StepperPage.tsx b/packages/storybook-pages/src/Pages/StepperPage/StepperPage.tsx index 2b6fada9..bbbb67c5 100644 --- a/packages/storybook-pages/src/Pages/StepperPage/StepperPage.tsx +++ b/packages/storybook-pages/src/Pages/StepperPage/StepperPage.tsx @@ -11,7 +11,7 @@ import { FullNameFields, SidebarMenu, } from '@smile/haring-react'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { menuMock } from '../BrowsingPage/BrowsingPage.mock'; @@ -45,40 +45,33 @@ async function getDataAddressGouvRequest( export function StepperPage(): ReactElement { const [active, setActive] = useState(0); - const [formData, setFormData] = useState({ - address: { - city: '', - country: '', - number: '', - postCode: '', - street: '', - }, - fullName: '', - }); - - const sidebarMenu = menuMock; const form = useForm({ - initialValues: formData, + initialValues: { + address: { + city: '', + country: '', + number: '', + postCode: '', + street: '', + }, + fullName: { + firstName: '', + lastName: '', + }, + }, }); const nextStep = (): void => { if (!form.validate().hasErrors) { - setFormData(form.values); setActive((current) => (current < 3 ? current + 1 : current)); } }; const prevStep = (): void => { - setFormData(form.values); setActive((current) => (current > 0 ? current - 1 : current)); }; - useEffect(() => { - form.setValues(formData); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - function onOptionSubmitMock( value: IValue, ): IAddressFieldsValues { @@ -91,13 +84,6 @@ export function StepperPage(): ReactElement { street: address.street ?? '', }; form.setFieldValue('address', newAddress); - setFormData((prevData) => { - const updatedData = { - ...prevData, - address: newAddress, - }; - return updatedData; - }); return newAddress; } @@ -105,7 +91,7 @@ export function StepperPage(): ReactElement { - + } > @@ -128,16 +114,6 @@ export function StepperPage(): ReactElement { postCode: values.postCode ?? '', street: values.street ?? '', }); - setFormData((prevData) => ({ - ...prevData, - address: { - city: values.city ?? '', - country: values.country ?? form.values.address.country, - number: values.number ?? '', - postCode: values.postCode ?? '', - street: values.street ?? '', - }, - })); }} onOptionSubmit={onOptionSubmitMock} />