-
Notifications
You must be signed in to change notification settings - Fork 16
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
The user can not save the information on 'Edit Profile' page after clicking on the 'Home page' #2937
base: develop
Are you sure you want to change the base?
Conversation
186c8d3
to
2c875f2
Compare
Quality Gate failedFailed conditions |
if (hasChanged) { | ||
const changes: Partial<EditProfileState> = { | ||
...changedCurrent | ||
} | ||
|
||
if (!hasChanges(changedInitial.videoLink, changedCurrent.videoLink)) { | ||
delete changes.videoLink | ||
} | ||
|
||
if (hasPhotoChanged) { | ||
changes.photo = changedCurrent.photo | ||
} | ||
|
||
return changes | ||
} else { | ||
return {} | ||
} |
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.
Try to replace this block with if-not
approach. You will not have an exta else
here.
@@ -103,6 +104,63 @@ const EditProfile = () => { | |||
} | |||
}, [loading, profileState, initialEditProfileState]) | |||
|
|||
const changedProfileFields = useMemo<Partial<EditProfileState>>(() => { | |||
if (!initialEditProfileState || !profileState) return {} |
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 would recommend you to not return {}
for non-changed profile fields. It's not obvious actualy.
Return null
if profile fields are not changed, it will simplify logic for isProfileChanged
variable calculation. You will have just const isProfileChanged = Boolean(changedProfileFields)
without useMemo
@@ -213,7 +271,41 @@ const EditProfile = () => { | |||
if (hash) { | |||
navigate(`${authRoutes.myProfile.path}#complete`) | |||
} | |||
} | |||
}, [profileState, changedFields]) |
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.
const changedProfileFields = useMemo<Partial<EditProfileState>>(() => { | ||
if (!initialEditProfileState || !profileState) return {} | ||
|
||
const changedInitial = { |
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.
Rename it, please.
const changedInitial = { | |
const initialProfileInformation = { |
videoLink: initialEditProfileState.videoLink | ||
} | ||
|
||
const changedCurrent = { |
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.
const changedCurrent = { | |
const changedProfileInformation = { |
videoLink: profileState.videoLink | ||
} | ||
|
||
const hasPhotoChanged = hasPhotoChanges( |
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.
const hasPhotoChanged = hasPhotoChanges( | |
const isPhotoChanged = hasPhotoChanges( |
changedCurrent.photo | ||
) | ||
|
||
const hasChanged = |
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.
const hasChanged = | |
const isProfileInformationChanged = |
Was result:
If user has unsaved changes and redirected to another page, he could do this without any information about unsaved changes.
Actual result:
If user has unsaved changes and want to go to another page, modal window appears about unsaved changes with propose to update or leave without changes.
Space2Study.-.Google.Chrome.2024-12-05.13-55-23.mp4