Skip to content

Commit

Permalink
Replace URL when adding new orgnr
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbb committed May 11, 2023
1 parent 8e26715 commit 6e34291
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/bedriftsmeny/velger/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ export const useOrgnrSearchParam: OrgnrSearchParamType = () => {
const navigate = useNavigate();

const setOrgnr = (orgnr: string) => {
if (currentOrgnr !== orgnr) {
if (orgnr === null) {
searchParam.delete(ORGNUMMER_PARAMETER);
} else {
searchParam.set(ORGNUMMER_PARAMETER, orgnr);
}
navigate({ search: searchParam.toString() });
if (currentOrgnr === orgnr) {
return;
}
if (orgnr === null) {
searchParam.delete(ORGNUMMER_PARAMETER);
} else {
searchParam.set(ORGNUMMER_PARAMETER, orgnr);
}
navigate(
{ search: searchParam.toString() },
{ replace: currentOrgnr === null }
);
};

return [currentOrgnr, setOrgnr];
Expand Down

0 comments on commit 6e34291

Please sign in to comment.