From 85969a581ae4f03e3fefe716e6f3d74c9ae8d12c Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Mon, 30 Dec 2024 23:42:26 +0900 Subject: [PATCH 1/3] Use GenderSelector in EditProfileForm --- .../ContactEditProfilePage/EditProfileForm.jsx | 14 +++----------- .../components/GenderSelector/GenderSelector.js | 3 ++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/webpacker/components/ContactEditProfilePage/EditProfileForm.jsx b/app/webpacker/components/ContactEditProfilePage/EditProfileForm.jsx index dd0e333d76b..cdabd1f0ede 100644 --- a/app/webpacker/components/ContactEditProfilePage/EditProfileForm.jsx +++ b/app/webpacker/components/ContactEditProfilePage/EditProfileForm.jsx @@ -5,22 +5,16 @@ import { QueryClient, useQuery } from '@tanstack/react-query'; import _ from 'lodash'; import I18n from '../../lib/i18n'; import { apiV0Urls, contactEditProfileActionUrl } from '../../lib/requests/routes.js.erb'; -import { genders } from '../../lib/wca-data.js.erb'; import Loading from '../Requests/Loading'; 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'; +import GenderSelector from '../GenderSelector/GenderSelector'; const CONTACT_EDIT_PROFILE_FORM_QUERY_CLIENT = new QueryClient(); -const genderOptions = _.map(genders.byId, (gender) => ({ - key: gender.id, - text: gender.name, - value: gender.id, -})); - export default function EditProfileForm({ wcaId, onContactSuccess, @@ -103,11 +97,9 @@ export default function EditProfileForm({ countryIso2={editedProfileDetails?.country_iso2} onChange={handleFormChange} /> - ({ value: gender.id, })); -function GenderSelector({ gender, onChange }) { +function GenderSelector({ name, gender, onChange }) { return ( Date: Mon, 30 Dec 2024 23:44:31 +0900 Subject: [PATCH 2/3] Use GenderSelector in EditPersonForm --- .../components/GenderSelector/GenderSelector.js | 8 +++++++- .../Panel/pages/EditPersonPage/EditPersonForm.jsx | 15 ++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/webpacker/components/GenderSelector/GenderSelector.js b/app/webpacker/components/GenderSelector/GenderSelector.js index d988e26d477..6d72ea08df3 100644 --- a/app/webpacker/components/GenderSelector/GenderSelector.js +++ b/app/webpacker/components/GenderSelector/GenderSelector.js @@ -10,7 +10,12 @@ const genderOptions = _.map(genders.byId, (gender) => ({ value: gender.id, })); -function GenderSelector({ name, gender, onChange }) { +function GenderSelector({ + name, + gender, + onChange, + disabled = false, +}) { return ( ); } diff --git a/app/webpacker/components/Panel/pages/EditPersonPage/EditPersonForm.jsx b/app/webpacker/components/Panel/pages/EditPersonPage/EditPersonForm.jsx index 25c95cc42bc..c1ac96d6f1f 100644 --- a/app/webpacker/components/Panel/pages/EditPersonPage/EditPersonForm.jsx +++ b/app/webpacker/components/Panel/pages/EditPersonPage/EditPersonForm.jsx @@ -7,16 +7,11 @@ import { adminCheckRecordsUrl, apiV0Urls } from '../../../../lib/requests/routes import useSaveAction from '../../../../lib/hooks/useSaveAction'; import Loading from '../../../Requests/Loading'; import I18n from '../../../../lib/i18n'; -import { genders, countries } from '../../../../lib/wca-data.js.erb'; +import { countries } from '../../../../lib/wca-data.js.erb'; import useLoadedData from '../../../../lib/hooks/useLoadedData'; import Errored from '../../../Requests/Errored'; import UtcDatePicker from '../../../wca/UtcDatePicker'; - -const genderOptions = _.map(genders.byId, (gender) => ({ - key: gender.id, - text: gender.name, - value: gender.id, -})); +import GenderSelector from '../../../GenderSelector/GenderSelector'; const countryOptions = _.map(countries.byIso2, (country) => ({ key: country.iso2, @@ -144,12 +139,10 @@ export default function EditPersonForm({ wcaId, onSuccess, showDestroyButton = f value={editedUserDetails?.representing || ''} onChange={handleFormChange} /> - Date: Mon, 30 Dec 2024 23:45:41 +0900 Subject: [PATCH 3/3] Localize GenderSelector label --- app/webpacker/components/GenderSelector/GenderSelector.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/webpacker/components/GenderSelector/GenderSelector.js b/app/webpacker/components/GenderSelector/GenderSelector.js index 6d72ea08df3..e195281f94c 100644 --- a/app/webpacker/components/GenderSelector/GenderSelector.js +++ b/app/webpacker/components/GenderSelector/GenderSelector.js @@ -3,6 +3,7 @@ import _ from 'lodash'; import { Form } from 'semantic-ui-react'; import { genders } from '../../lib/wca-data.js.erb'; +import I18n from '../../lib/i18n'; const genderOptions = _.map(genders.byId, (gender) => ({ key: gender.id, @@ -19,7 +20,7 @@ function GenderSelector({ return (