import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CustomerOrderDetailsComponent, CustomerOrderDetailsModule } from './customer-order-details';
import { CustomerOrderEditComponent } from './customer-order-edit';
import {
  CustomerOrderSearchComponent,
  CustomerOrderSearchFilterComponent,
  CustomerOrderSearchModule,
} from './customer-order-search';
import { CustomerOrderSearchMainComponent, CustomerOrderSearchMainModule } from './customer-order-search/search-main';
import {
  CustomerOrderSearchResultsComponent,
  CustomerOrderSearchResultsModule,
} from './customer-order-search/search-results';
import { CustomerOrderComponent } from './customer-order.component';
import { CustomerOrderHistoryComponent } from './customer-order-history';

const routes: Routes = [
  {
    path: '',
    component: CustomerOrderComponent,
    children: [
      {
        path: 'filter',
        component: CustomerOrderSearchFilterComponent,
      },
      {
        path: 'filter/:orderId/:compartmentCode/:processingStatus',
        component: CustomerOrderSearchFilterComponent,
      },
      {
        path: 'filter/:orderId/:processingStatus',
        component: CustomerOrderSearchFilterComponent,
      },
      {
        path: 'search',
        component: CustomerOrderSearchComponent,
        outlet: 'side',
        children: [
          {
            path: '',
            component: CustomerOrderSearchMainComponent,
          },
        ],
      },
      {
        path: 'results',
        component: CustomerOrderSearchResultsComponent,
        outlet: 'side',
      },
      {
        path: 'results/:orderId/:processingStatus',
        component: CustomerOrderSearchResultsComponent,
        outlet: 'side',
      },
      {
        path: 'results/:orderId/:compartmentCode/:processingStatus',
        component: CustomerOrderSearchResultsComponent,
        outlet: 'side',
      },
      {
        path: 'results',
        component: CustomerOrderSearchResultsComponent,
      },
      {
        path: 'details/:orderId/:processingStatus',
        component: CustomerOrderDetailsComponent,
      },
      {
        path: 'details/:orderId/:compartmentCode/:processingStatus/edit',
        component: CustomerOrderEditComponent,
      },
      {
        path: 'details/:orderId/:processingStatus/edit',
        component: CustomerOrderEditComponent,
      },
      {
        path: 'details/:orderId/:compartmentCode/:processingStatus/history',
        component: CustomerOrderHistoryComponent,
      },
      {
        path: 'details/:orderId/:processingStatus/history',
        component: CustomerOrderHistoryComponent,
      },
      {
        path: 'details/:orderId/:compartmentCode/:processingStatus',
        component: CustomerOrderDetailsComponent,
      },
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'filter',
      },
    ],
  },
];
@NgModule({
  imports: [
    RouterModule.forChild(routes),
    CustomerOrderSearchModule,
    CustomerOrderSearchMainModule,
    CustomerOrderSearchResultsModule,
    CustomerOrderDetailsModule,
  ],
  exports: [RouterModule],
})
export class CustomerOrderRoutingModule {}
