import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ArticleDetailsComponent } from './article-details/article-details.component';
import { ArticleSearchComponent } from './article-search/article-search.component';
import { ArticleSearchMainComponent } from './article-search/search-main/search-main.component';
import { ArticleSearchResultsComponent } from './article-search/search-results/search-results.component';
import { PageCatalogComponent } from './page-catalog.component';

const routes: Routes = [
  {
    path: '',
    component: PageCatalogComponent,
    children: [
      {
        path: 'search',
        component: ArticleSearchComponent,
        children: [
          {
            path: '',
            component: ArticleSearchMainComponent,
          },
          {
            path: 'results',
            component: ArticleSearchResultsComponent,
          },
        ],
      },
      {
        path: 'details/ean/:ean',
        component: ArticleDetailsComponent,
      },
      {
        path: 'details/:id',
        component: ArticleDetailsComponent,
      },
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'search',
      },
    ],
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class PageCatalogRoutingModule {}
