-
Notifications
You must be signed in to change notification settings - Fork 182
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
updated country selector #10354
base: main
Are you sure you want to change the base?
updated country selector #10354
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ import Errored from '../Requests/Errored'; | |
import useSaveAction from '../../lib/hooks/useSaveAction'; | ||
import { fetchJsonOrError } from '../../lib/requests/fetchWithAuthenticityToken'; | ||
import UtcDatePicker from '../wca/UtcDatePicker'; | ||
import CountrySelector from '../CountrySelector/CountrySelector'; | ||
|
||
const CONTACT_EDIT_PROFILE_FORM_QUERY_CLIENT = new QueryClient(); | ||
|
||
|
@@ -19,12 +20,6 @@ const genderOptions = _.map(genders.byId, (gender) => ({ | |
value: gender.id, | ||
})); | ||
|
||
const countryOptions = _.map(countries.byIso2, (country) => ({ | ||
key: country.iso2, | ||
text: country.name, | ||
value: country.iso2, | ||
})); | ||
|
||
export default function EditProfileForm({ | ||
wcaId, | ||
onContactSuccess, | ||
|
@@ -82,7 +77,10 @@ export default function EditProfileForm({ | |
}; | ||
|
||
const handleFormChange = (e, { name: formName, value }) => { | ||
setEditedProfileDetails((prev) => ({ ...prev, [formName]: value })); | ||
setEditedProfileDetails((prev) => { | ||
const newState = { ...prev, [formName]: value }; | ||
return newState; | ||
}); | ||
}; | ||
|
||
const handleDobChange = (date) => handleFormChange(null, { | ||
|
@@ -102,13 +100,10 @@ export default function EditProfileForm({ | |
onChange={handleFormChange} | ||
required | ||
/> | ||
<Form.Select | ||
options={countryOptions} | ||
<CountrySelector | ||
label={i18n.t('activerecord.attributes.user.country_iso2')} | ||
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.
|
||
name="country_iso2" | ||
search | ||
value={editedProfileDetails?.country_iso2} | ||
onChange={handleFormChange} | ||
selected={editedProfileDetails?.country_iso2} | ||
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.
|
||
onChange={(event, data) => handleFormChange(null, { name: 'country_iso2', value: data.value })} | ||
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. If you keep passing in |
||
/> | ||
<Form.Select | ||
options={genderOptions} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think putting it on two lines is necessary