Skip to content

Legg til url-parameter for org på systembruker-oversikt siden - #2283

Open
mgunnerud wants to merge 1 commit into
mainfrom
feat/3296-legg-til-query-param-for-a-bytte-til-gitt-virksomhet-for-systembruker
Open

Legg til url-parameter for org på systembruker-oversikt siden#2283
mgunnerud wants to merge 1 commit into
mainfrom
feat/3296-legg-til-query-param-for-a-bytte-til-gitt-virksomhet-for-systembruker

Conversation

@mgunnerud

@mgunnerud mgunnerud commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

  • Legg til org parameter som tar inn et organisasjonsnummer på systembruker-oversikt siden. Hvis dette er satt, last aktørlisten for gitt bruker, og se om dette orgnr finnes der. Hvis det gjør det, bytt til denne orgen. Systemleverandører vil bruke dette for å linke til systembrukeroversikten fra sitt system, så slipper de at etter bruker logger inn havner på systembruker-oversikt for seg selv som privatperson

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • Bug Fixes
    • System User Overview page now properly handles organization parameters in the URL and automatically redirects to the correct reportee when an organization mismatch is detected.

@github-actions github-actions Bot added the kind/feature-request Used when issue is a new feature or request label Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

SystemUserOverviewPage now reads an org query parameter and validates the current reportee against the authorized user's available reportees. If the current reportee's organization does not match the org value, it redirects to the matching reportee while removing the org parameter from the URL.

Changes

Organization Reportee Validation and Redirect

Layer / File(s) Summary
Hook imports and search parameter setup
src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx
Updated React and React Router imports to include useEffect and useSearchParams; added imports for the reportee-list query and redirectToChangeReporteeAndRedirect utility.
Organization validation and conditional redirect
src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx
Added conditional useGetReporteeListForAuthorizedUserQuery that fetches only when org is present; introduced useEffect that matches the current reportee by organization number and triggers a redirect to the matching reportee when the organizations do not align.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • sonwit
  • allinox

Poem

🔗 A query param flies in, seeking its reportee home,
We check the organization, through the data we roam,
If names don't align, we kindly redirect—
The right person's path, we gently correct. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a URL parameter 'org' to the system user overview page, which is the primary functionality introduced in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3296-legg-til-query-param-for-a-bytte-til-gitt-virksomhet-for-systembruker

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx (1)

82-98: 💤 Low value

Org param removed from URL even when no matching reportee is found.

The setSearchParams call (lines 86-90) executes before validating matchingReportee (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

📥 Commits

Reviewing files that changed from the base of the PR and between 3603ce3 and ee00ba2.

📒 Files selected for processing (1)
  • src/features/amUI/systemUser/SystemUsersOverviewPage/SystemUserOverviewPage.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature-request Used when issue is a new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legg til query-param for å bytte til gitt virksomhet for systembruker

1 participant