-
Notifications
You must be signed in to change notification settings - Fork 203
Modify edit profile form by requiring edit reason for each field #14331
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
Open
danieljames-dj
wants to merge
3
commits into
thewca:main
Choose a base branch
from
danieljames-dj:edit-reason-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/webpacker/components/ContactEditProfilePage/EditProfileFormHolder.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import React from 'react'; | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { apiV0Urls } from '../../lib/requests/routes.js.erb'; | ||
| import { fetchJsonOrError } from '../../lib/requests/fetchWithAuthenticityToken'; | ||
| import Loading from '../Requests/Loading'; | ||
| import Errored from '../Requests/Errored'; | ||
| import EditProfileForm from './EditProfileForm'; | ||
|
|
||
| export default function EditProfileFormHolder({ | ||
| wcaId, | ||
| onContactSuccess, | ||
| recaptchaPublicKey, | ||
| }) { | ||
| const { data, isLoading, isError } = useQuery({ | ||
| queryKey: ['profileData', wcaId], | ||
| queryFn: () => fetchJsonOrError(apiV0Urls.persons.show(wcaId)), | ||
| }); | ||
|
|
||
| if (isLoading) return <Loading />; | ||
| if (isError) return <Errored />; | ||
|
|
||
| const profileDetails = data?.data?.person; | ||
|
|
||
| return ( | ||
| <EditProfileForm | ||
| wcaId={wcaId} | ||
| profileDetails={profileDetails} | ||
| onContactSuccess={onContactSuccess} | ||
| recaptchaPublicKey={recaptchaPublicKey} | ||
| /> | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
app/webpacker/components/ContactEditProfilePage/fields/EditDobField.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import React from 'react'; | ||
| import { Form } from 'semantic-ui-react'; | ||
| import I18n from '../../../lib/i18n'; | ||
| import UtcDatePicker from '../../wca/UtcDatePicker'; | ||
| import EditReasonField from './EditReasonField'; | ||
|
|
||
| export default function EditDobField({ | ||
| value, reason, isChanged, onValueChange, onReasonChange, | ||
| }) { | ||
| return ( | ||
| <> | ||
| <Form.Field | ||
| label={I18n.t('activerecord.attributes.user.dob')} | ||
| name="dob" | ||
| control={UtcDatePicker} | ||
| showYearDropdown | ||
| dateFormatOverride="yyyy-MM-dd" | ||
| dropdownMode="select" | ||
| isoDate={value} | ||
| onChange={(date) => onValueChange(null, { name: 'dob', value: date })} | ||
| required | ||
| /> | ||
| <EditReasonField | ||
| name="dob" | ||
| label={I18n.t('activerecord.attributes.user.dob')} | ||
| isChanged={isChanged} | ||
| value={reason} | ||
| onChange={onReasonChange} | ||
| /> | ||
| </> | ||
| ); | ||
| } |
25 changes: 25 additions & 0 deletions
25
app/webpacker/components/ContactEditProfilePage/fields/EditGenderField.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
| import GenderSelector from '../../wca/GenderSelector'; | ||
| import EditReasonField from './EditReasonField'; | ||
| import I18n from '../../../lib/i18n'; | ||
|
|
||
| export default function EditGenderField({ | ||
| value, reason, isChanged, onValueChange, onReasonChange, | ||
| }) { | ||
| return ( | ||
| <> | ||
| <GenderSelector | ||
| name="gender" | ||
| gender={value} | ||
| onChange={onValueChange} | ||
| /> | ||
| <EditReasonField | ||
| name="gender" | ||
| label={I18n.t('activerecord.attributes.user.gender')} | ||
| isChanged={isChanged} | ||
| value={reason} | ||
| onChange={onReasonChange} | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
app/webpacker/components/ContactEditProfilePage/fields/EditNameField.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import React from 'react'; | ||
| import { Form } from 'semantic-ui-react'; | ||
| import I18n from '../../../lib/i18n'; | ||
| import EditReasonField from './EditReasonField'; | ||
|
|
||
| export default function EditNameField({ | ||
| value, reason, isChanged, onValueChange, onReasonChange, | ||
| }) { | ||
| return ( | ||
| <> | ||
| <Form.Input | ||
| label={I18n.t('activerecord.attributes.user.name')} | ||
| name="name" | ||
| value={value || ''} | ||
| onChange={onValueChange} | ||
| required | ||
| /> | ||
| <EditReasonField | ||
| name="name" | ||
| label={I18n.t('activerecord.attributes.user.name')} | ||
| isChanged={isChanged} | ||
| value={reason} | ||
| onChange={onReasonChange} | ||
| /> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What do you think about not requiring a reason for gender change?
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.
That's a really good point, but I like to take it up in a follow-up PR in a different way. This PR aims to have text field for all the reasons, and the improvements for each of them will be a separate problem to solve.
For DOB, instead of not making reason mandatory, I prefer giving user the option to tick a checkbox which says that they agree that this change must be done, [...]. This way we will get an extra validation from user that they are finen with this change.
Uh oh!
There was an error while loading. Please reload this page.
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.
Unfortunately what Maks pointed out is a politically sensitive topic. Requiring this change -- even though it makes sense "for now" in your code architecture -- may still put pressure on transgender individuals who want to submit a profile change five minutes after this PR was deployed. We do not want that pressure.
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.
Okay, I would like to inform that this is even the current behavior - so the pressure already exists. I was just trying to keep the existing behavior as it is.
Here are the things I can do here:
EditReasonField, and for gender I'll have a radio button options where first option (default) will be "I prefer not to answer", and second option will be "I would like to give an explanation". If user clicks second option, then they will have the 'edit reason' field which will now become mandatory.@gregorbg Which option do you prefer here?