Fix: Incorrect Error Message and UI issues for Non-Super Users on Request Actions #961
Fix: Incorrect Error Message and UI issues for Non-Super Users on Request Actions #961iamitprakash merged 1 commit intoRealDevSquad:developfrom mridxl:Fix/requests-toast-fix
Conversation
Summary by CodeRabbit
WalkthroughThe pull request adds a new error message constant for unauthorized actions in the application's error handling. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ReqHandler as acceptRejectRequest
participant ActionHandler as performAcceptRejectAction
participant UI as renderRequestCards
participant ErrMsg as ErrorMessages
User->>ReqHandler: Trigger acceptRejectRequest
alt HTTP 401 Response
ReqHandler->>ErrMsg: Retrieve UNAUTHORIZED_ACTION message
ErrMsg--)ReqHandler: Return error message
else HTTP 403 Response
ReqHandler->>ErrMsg: Retrieve UNAUTHENTICATED message
ErrMsg--)ReqHandler: Return error message
end
ActionHandler->>ActionHandler: Reset nextLink to empty
ActionHandler->>UI: Re-render request cards (current state & sort)
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
|
Could you please add a video in the description for better clarity? Also, is it appropriate to display the error message in both the toast and the body? |
Yes, I've added the video in the description.
The error message was being displayed in the body earlier, so I assumed that was how we wanted it to be. |
A toast seems sufficient for notifying the user—maybe we can check with others for their input. Also, since we're re-rendering the cards, is there a way to prevent that when an error occurs to avoid an extra DB call? |
|
@mridxl remove |
Yes, we can consider one of two approaches:
I prefer the second approach. Since the state of the requests doesn’t change when an error occurs, there’s no need to modify the UI. We can just show the user an error toast to notify them of the issue. If the API call is successful, we can then refetch the requests and re-render the cards (along with a loading spinner to indicate the update). |
/requests
/requests
Date: 14 Mar 2025
Developer Name: @mridxl
Issue Ticket Number
Description
This PR fixes the incorrect error message shown when a non-super user clicks the "Accept" or "Reject" button on requests. Additionally, it ensures that request cards remain visible on the page instead of disappearing when an error occurs. The error message will now be displayed only via a toast notification without altering the state of the request list.
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Screenshot 1
Screen Recording
Recording.2025-03-14.170913.mp4
Test Coverage
Screenshot 1