import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PageNotFoundComponent } from '@shared/error-handling/page-not-found/page-not-found.component';
import { StaffComponent } from './staff/staff/staff.component';
import { EnduserComponent } from './enduser/enduser/enduser.component';
import { CurrentUserResolver } from '@shared/auth/current-user.resolver';
import { urlMatcher } from '@shared/ui/common/utils';

const routes: Routes = [
  {
    path: 'staff',
    loadChildren: () => import('./staff/staff.module').then(mod => mod.StaffModule),
    component: StaffComponent,
    data: {
      configurationName: 'staff',
      hideInBreadcrumbs: true,
    },
    resolve: {
      currentUser: CurrentUserResolver
    },
  },
  {
    matcher: urlMatcher,
    loadChildren: () => import('./enduser/enduser.module').then(mod => mod.EnduserModule),
    component: EnduserComponent,
    data: {
      configurationName: 'enduser',
      hideInBreadcrumbs: true,
    },
    resolve: {
      currentUser: CurrentUserResolver
    },
  },
  {
    path: '**',
    component: PageNotFoundComponent,
    resolve: {
      currentUser: CurrentUserResolver
    },
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {onSameUrlNavigation: 'reload'})],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
