Legg til url-parameter for org på systembruker-oversikt siden - #2283
Legg til url-parameter for org på systembruker-oversikt siden#2283mgunnerud wants to merge 1 commit into
Conversation
… given org number
📝 WalkthroughWalkthrough
ChangesOrganization Reportee Validation and Redirect
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx (1)
82-98: 💤 Low valueOrg param removed from URL even when no matching reportee is found.
The
setSearchParamscall (lines 86-90) executes before validatingmatchingReportee(line 91). If the org doesn't exist in the user's authorized list, the param is silently removed with no redirect or user feedback.If this is intentional (clean URL regardless of outcome), consider adding a brief comment for clarity. Otherwise, move the param removal inside the
if (matchingReportee ...)block or provide feedback when no match is found.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx` around lines 82 - 98, The org query param is being removed unconditionally before we verify a matching reportee; move the setSearchParams call so it only runs when a matchingReportee is found (i.e., inside the if (matchingReportee && reporteeData?.organizationNumber !== org) block) or, if you intentionally want to always clean the URL, add a comment near useEffect explaining that behavior; update the block around useEffect/searchParams/reporteeList/matchingReportee to either relocate the next.delete('org') call into the matchingReportee branch or add the clarifying comment to prevent silent removal when no authorized reportee exists and to keep logic clear for redirectToChangeReporteeAndRedirect.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx`:
- Around line 78-80: The reporteeList query result lacks error-state handling:
update the call to useGetReporteeListForAuthorizedUserQuery to also destructure
isError (e.g., const { data: reporteeList, isError: isReporteeListError } =
...), then in the existing useEffect (that reads searchParams and reporteeList)
or in a separate effect check isReporteeListError and either remove the 'org'
param from searchParams (so it doesn't persist on failure) or trigger UI
feedback/error state to the user; ensure you reference reporteeList,
isReporteeListError, useGetReporteeListForAuthorizedUserQuery, searchParams and
the useEffect that currently depends on reporteeList when applying the change.
---
Nitpick comments:
In
`@src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx`:
- Around line 82-98: The org query param is being removed unconditionally before
we verify a matching reportee; move the setSearchParams call so it only runs
when a matchingReportee is found (i.e., inside the if (matchingReportee &&
reporteeData?.organizationNumber !== org) block) or, if you intentionally want
to always clean the URL, add a comment near useEffect explaining that behavior;
update the block around useEffect/searchParams/reporteeList/matchingReportee to
either relocate the next.delete('org') call into the matchingReportee branch or
add the clarifying comment to prevent silent removal when no authorized reportee
exists and to keep logic clear for redirectToChangeReporteeAndRedirect.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8294cca0-0b27-402a-8f54-9dc1ee9c9978
📒 Files selected for processing (1)
src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx
Description
Related Issue(s)
Verification
Documentation
Summary by CodeRabbit