-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Update country and state when the draft is updated #85547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, {useCallback, useState} from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, {useCallback, useRef, useState} from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {View} from 'react-native'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import AddressSearch from '@components/AddressSearch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import CountryPicker from '@components/CountryPicker'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -26,11 +26,26 @@ function AddressStep({isEditing, onNext, personalDetailsValues}: CustomSubPagePr | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| const {translate} = useLocalize(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const styles = useThemeStyles(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [currentCountry, setCurrentCountry] = useState(personalDetailsValues[INPUT_IDS.COUNTRY]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [state, setState] = useState(personalDetailsValues[INPUT_IDS.STATE]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentCountryDraft = personalDetailsValues[INPUT_IDS.COUNTRY]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentStateDraft = personalDetailsValues[INPUT_IDS.STATE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [currentCountry, setCurrentCountry] = useState(currentCountryDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [state, setState] = useState(currentStateDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [city, setCity] = useState(personalDetailsValues[INPUT_IDS.CITY]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [zipcode, setZipcode] = useState(personalDetailsValues[INPUT_IDS.ZIP_POST_CODE]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const prevCountryDraft = useRef(currentCountryDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const prevStateDraft = useRef(currentStateDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (prevCountryDraft.current !== currentCountryDraft) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prevCountryDraft.current = currentCountryDraft; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setCurrentCountry(currentCountryDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (prevStateDraft.current !== currentStateDraft) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prevStateDraft.current = currentStateDraft; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setState(currentStateDraft); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use the same approach we used in FormProvider. We need to update the local state here because we use it as the input App/src/pages/MissingPersonalDetails/subPages/Address.tsx Lines 165 to 188 in e149717
And FormProvider will show the value from App/src/components/Form/FormProvider.tsx Lines 333 to 334 in e149717
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleSubmit = usePersonalDetailsFormSubmit({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fieldIds: STEP_FIELDS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onNext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.