-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[WEB-2857]fix: updating user role in profile #6278
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Sequence DiagramsequenceDiagram
participant User
participant ProfilePage
participant UserHook
participant ProfileHook
participant API
User->>ProfilePage: Update Profile
ProfilePage->>UserHook: Get Current User
ProfilePage->>ProfileHook: Get User Profile
ProfilePage->>ProfilePage: Prepare Payloads
ProfilePage->>API: Update User (Parallel)
ProfilePage->>API: Update Profile
API-->>ProfilePage: Update Confirmation
ProfilePage->>User: Show Success Message
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
web/app/profile/page.tsx (3)
30-30
: Validate the combined usage ofuseUser
anduseUserProfile
.While splitting user data and user profile data can improve semantic clarity, confirm that this separation won't introduce race conditions or partial updates. If these updates are meant to be atomic, consider consolidating them.
62-62
: Check naming consistency and clarity.The variable
currentUserProfile
closely parallelscurrentUser
. Consider consistently naming them (e.g.,userProfile
vs.currentUserProfile
) for clarity across the codebase.
77-79
: Use optional chaining carefully.
formData.role ?? undefined
works, but confirm that returningundefined
is the intended behavior whenrole
is absent, rather than preserving a default role or skipping the field entirely.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/app/profile/page.tsx
(3 hunks)
🔇 Additional comments (5)
web/app/profile/page.tsx (5)
8-8
: Use the newly imported TUserProfile
judiciously.
Importing TUserProfile
is good for typing your user profile data. Ensure that it's used consistently across the file and that the shape of the user profile in the store/context aligns with this new type.
65-65
: Ensure correct priority during form reset.
Combining defaultValues
, currentUser
, and currentUserProfile
is helpful for a comprehensive reset. Verify that merging these objects does not accidentally overwrite fields from the other sources.
70-70
: Confirm completeness of the user payload.
You might also consider including role
in the userPayload
if a user’s role in the user entity must always mirror the profile’s role. If this is intentional, disregard.
82-83
: Cover image logic might cause confusion.
If formData.cover_image_url
starts with http
, the logic sets cover_image
but clears cover_image_asset
. Confirm that all references to cover images consistently read from cover_image
or cover_image_asset
. Mismatches can lead to unexpected display behavior.
86-89
: Parallel updates look good.
The Promise.all
usage to update both the user and user profile is efficient. The success and error handling flow is clearly defined. Great job!
Description
This update ensures that the user's role is properly updated when the profile is submitted.
The
updateUserProfile
function is now included in thePromise.all
call within theonSubmit
function to handle role updates.Type of Change
References
WEB-2857
Summary by CodeRabbit
New Features
Bug Fixes
Improvements