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 { ArticleSearchFilterComponent } from './article-search/search-filter/search-filter.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';
import { MatomoRouteData } from 'ngx-matomo-client';

const routes: Routes = [
  {
    path: '',
    component: PageCatalogComponent,
    title: 'Artikelsuche',
    data: {
      matomo: {
        title: 'Artikelsuche',
      } as MatomoRouteData,
    },
    children: [
      {
        path: 'filter',
        component: ArticleSearchFilterComponent,
        title: 'Artikelsuche - Filter',
        data: {
          matomo: {
            title: 'Artikelsuche - Filter',
          } as MatomoRouteData,
        },
      },
      {
        path: 'filter/:id',
        component: ArticleSearchFilterComponent,
        title: 'Artikelsuche - Filter',
        data: {
          matomo: {
            title: 'Artikelsuche - Filter',
          } as MatomoRouteData,
        },
      },
      {
        path: 'search',
        component: ArticleSearchComponent,
        outlet: 'side',
        title: 'Artikelsuche',
        data: {
          matomo: {
            title: 'Artikelsuche',
          } as MatomoRouteData,
        },
        children: [
          {
            path: '',
            component: ArticleSearchMainComponent,
          },
        ],
      },
      {
        path: 'results',
        component: ArticleSearchResultsComponent,
        title: 'Artikelsuche - Trefferliste',
        data: {
          matomo: {
            title: 'Artikelsuche - Trefferliste',
          } as MatomoRouteData,
        },
      },
      {
        path: 'results',
        component: ArticleSearchResultsComponent,
        outlet: 'side',
        title: 'Artikelsuche - Trefferliste',
        data: {
          matomo: {
            title: 'Artikelsuche - Trefferliste',
          } as MatomoRouteData,
        },
      },
      {
        path: 'results/:id',
        component: ArticleSearchResultsComponent,
        outlet: 'side',
        title: 'Artikelsuche - Artikeldetails',
        data: {
          matomo: {
            title: 'Artikelsuche - Artikeldetails',
          } as MatomoRouteData,
        },
      },
      {
        path: 'results/:ean/ean',
        component: ArticleSearchResultsComponent,
        outlet: 'side',
        title: 'Artikelsuche - Artikeldetails (EAN)',
        data: {
          matomo: {
            title: 'Artikelsuche - Artikeldetails (EAN)',
          } as MatomoRouteData,
        },
      },
      {
        path: 'details/:id',
        component: ArticleDetailsComponent,
        title: 'Artikelsuche - Artikeldetails (ID)',
        data: {
          matomo: {
            title: 'Artikelsuche - Artikeldetails (ID)',
          } as MatomoRouteData,
        },
      },
      {
        path: 'details/:ean/ean',
        component: ArticleDetailsComponent,
        title: 'Artikelsuche - Artikeldetails (EAN)',
        data: {
          matomo: {
            title: 'Artikelsuche - Artikeldetails (EAN)',
          } as MatomoRouteData,
        },
      },
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'filter',
      },
    ],
  },
];

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