From d2560b628309d6d92496155a6071dabcda6bf72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Marie=20CL=C3=89RY?= Date: Fri, 18 Oct 2024 17:57:21 +0200 Subject: [PATCH] =?UTF-8?q?(PC-32445)[PRO]=20fix:=20Re-render=20Formik=20f?= =?UTF-8?q?orm=20with=20good=20values=20when=20SWR=20call=20returned=20ven?= =?UTF-8?q?ues=20This=20will=20fix=20the=20problem=20of=20"=C3=80=20une=20?= =?UTF-8?q?autre=20adresse"=20is=20selected=20after=20a=20F5=20refresh=20w?= =?UTF-8?q?hereas=20offer=20has=20a=20selected=20venue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndividualOfferForm/OfferLocation/OfferLocation.tsx | 7 ++++++- .../UsefulInformationScreen/UsefulInformationScreen.tsx | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pro/src/components/IndividualOfferForm/OfferLocation/OfferLocation.tsx b/pro/src/components/IndividualOfferForm/OfferLocation/OfferLocation.tsx index 8d95c040728..3d1fed9cd1e 100644 --- a/pro/src/components/IndividualOfferForm/OfferLocation/OfferLocation.tsx +++ b/pro/src/components/IndividualOfferForm/OfferLocation/OfferLocation.tsx @@ -1,5 +1,5 @@ import { useField, useFormikContext } from 'formik' -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import { VenueListItemResponseModel } from 'apiClient/v1' import { AddressSelect } from 'components/Address/Address' @@ -30,6 +30,11 @@ export const OfferLocation = ({ venue }: OfferLocationProps): JSX.Element => { const [showOtherAddress, setShowOtherAddress] = useState( formik.values.offerlocation === OFFER_LOCATION.OTHER_ADDRESS ) + + useEffect(() => { + setShowOtherAddress(formik.values.offerlocation === 'other') + }, [formik.values.offerlocation]) + const [manuallySetAddress, , { setValue: setManuallySetAddress }] = useField('manuallySetAddress') diff --git a/pro/src/screens/IndividualOffer/UsefulInformationScreen/UsefulInformationScreen.tsx b/pro/src/screens/IndividualOffer/UsefulInformationScreen/UsefulInformationScreen.tsx index 3fa4610a329..05a0812fd29 100644 --- a/pro/src/screens/IndividualOffer/UsefulInformationScreen/UsefulInformationScreen.tsx +++ b/pro/src/screens/IndividualOffer/UsefulInformationScreen/UsefulInformationScreen.tsx @@ -213,6 +213,7 @@ export const UsefulInformationScreen = ({ initialValues, onSubmit, validationSchema, + enableReinitialize: true, }) const handlePreviousStepOrBackToReadOnly = () => { if (mode === OFFER_WIZARD_MODE.CREATION) {