Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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,
Expand Down Expand Up @@ -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, {
Expand All @@ -102,13 +100,10 @@ export default function EditProfileForm({
onChange={handleFormChange}
required
/>
<Form.Select
options={countryOptions}
<CountrySelector
label={i18n.t('activerecord.attributes.user.country_iso2')}
name="country_iso2"
search
value={editedProfileDetails?.country_iso2}
onChange={handleFormChange}
selected={editedProfileDetails?.country_iso2}
onChange={(event, data) => handleFormChange(null, { name: 'country_iso2', value: data.value })}
/>
<Form.Select
options={genderOptions}
Expand Down
Loading