diff --git a/frontend/app-preview/src/components/AppBarConfig/AppPreviewBarConfig.tsx b/frontend/app-preview/src/components/AppBarConfig/AppPreviewBarConfig.tsx index a94ab5dba22..a5579ddcdfa 100644 --- a/frontend/app-preview/src/components/AppBarConfig/AppPreviewBarConfig.tsx +++ b/frontend/app-preview/src/components/AppBarConfig/AppPreviewBarConfig.tsx @@ -102,7 +102,7 @@ export const appPreviewButtonActions = ( instanceId: string, ): AltinnButtonActionItem[] => { const packagesRouter = new PackagesRouter({ org, app }); - const subUrl = `?layout=${window.localStorage.getItem(instanceId)}`; + const queryParams = `?layout=${window.localStorage.getItem(instanceId)}`; const action: AltinnButtonActionItem[] = [ { @@ -110,7 +110,7 @@ export const appPreviewButtonActions = ( menuKey: TopBarMenu.Preview, buttonVariant: 'secondary', headerButtonsClasses: classes.backToEditorBtn, - handleClick: () => packagesRouter.navigateToPackage('editorUiEditor', subUrl), + handleClick: () => packagesRouter.navigateToPackage('editorUiEditor', queryParams), }, ]; return action; diff --git a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts index c6204cfd3a3..a7930f5a518 100644 --- a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts +++ b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.test.ts @@ -6,7 +6,7 @@ const mockApp: string = 'app'; describe('PackagesRouter', () => { describe('constructor', () => { it('should default to empty strings if app and org are not provided', () => { - const routerWithoutParams = new PackagesRouter({}); + const routerWithoutParams = new PackagesRouter(); expect(routerWithoutParams['app']).toEqual(''); expect(routerWithoutParams['org']).toEqual(''); }); diff --git a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts index 9e2a1207761..5f6515aa770 100644 --- a/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts +++ b/frontend/packages/shared/src/navigation/PackagesRouter/PackagesRouter.ts @@ -22,9 +22,9 @@ export class PackagesRouter { private app: string; private org: string; - constructor(private paramsOptions: ParamsOptions) { - this.app = this.paramsOptions.app ?? ''; - this.org = this.paramsOptions.org ?? ''; + constructor(private paramsOptions?: ParamsOptions) { + this.app = this.paramsOptions?.app ?? ''; + this.org = this.paramsOptions?.org ?? ''; } public navigateToPackage(packageRoute: PackagesRoute, queryParams?: string): void {