import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AddProductComponent, AddProductModule } from './add-product';
import { RemissionListComponent } from './remission-list';
import { RemissionListModule } from './remission-list/remission-list.module';
import { RemissionComponent } from './remission.component';
import { ShippingDocumentDetailsComponent } from './shipping-document-list/shipping-document-details/shipping-document-details.component';
import { ShippingDocumentListComponent } from './shipping-document-list/shipping-document-list.component';
import { ShippingDocumentListModule } from './shipping-document-list/shipping-document-list.module';
import { CreateRemissionModule } from './create-remission/create-remission.module';
import { CreateRemissionComponent } from './create-remission/create-remission.component';
import { FinishShippingDocumentComponent } from './finish-shipping-document/finish-shipping-document.component';
import { FinishShippingDocumentModule } from './finish-shipping-document/finish-shipping-document.module';
import { FinishRemissionModule } from './finish-remission/finish-remission.module';
import { FinishRemissionComponent } from './finish-remission/finish-remission.component';

const routes: Routes = [
  {
    path: '',
    component: RemissionComponent,
    children: [
      {
        path: 'list',
        component: RemissionListComponent,
      },
      {
        path: ':returnId/list',
        component: RemissionListComponent,
      },
      {
        path: ':returnId/shipping-document',
        component: ShippingDocumentDetailsComponent,
      },
      {
        path: 'add-product',
        component: AddProductComponent,
      },
      {
        path: 'shipping-documents',
        component: ShippingDocumentListComponent,
      },
      {
        path: 'shipping-documents/:id',
        component: ShippingDocumentDetailsComponent,
      },
      {
        path: 'create',
        component: CreateRemissionComponent,
      },
      {
        path: 'create/:returnGroup',
        component: CreateRemissionComponent,
      },
      {
        path: ':returnId/finish-shipping-document/:receiptId',
        component: FinishShippingDocumentComponent,
      },
      {
        path: ':returnId/finish-remission',
        component: FinishRemissionComponent,
      },
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'list',
      },
    ],
  },
];

@NgModule({
  imports: [
    RouterModule.forChild(routes),
    RemissionListModule,
    AddProductModule,
    ShippingDocumentListModule,
    CreateRemissionModule,
    FinishShippingDocumentModule,
    FinishRemissionModule,
  ],
  exports: [RouterModule],
})
export class RemissionRoutingModule {}
