import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CheckoutReviewComponent } from './checkout-review/checkout-review.component';
import { CheckoutSummaryComponent } from './checkout-summary/checkout-summary.component';
import { PageCheckoutComponent } from './page-checkout.component';
import { CheckoutReviewDetailsComponent } from './checkout-review/details/checkout-review-details.component';
import { canDeactivateTabCleanup } from '@isa/core/tabs';

const routes: Routes = [
  {
    path: '',
    component: PageCheckoutComponent,
    children: [
      {
        path: 'details',
        component: CheckoutReviewDetailsComponent,
        title: 'Bestelldetails',
        outlet: 'side',
      },
      {
        path: 'review',
        component: CheckoutReviewComponent,
        title: 'Bestellung überprüfen',
      },
      {
        path: 'summary',
        component: CheckoutSummaryComponent,
        title: 'Bestellübersicht',
        canDeactivate: [canDeactivateTabCleanup],
      },
      {
        path: 'summary/:orderIds',
        component: CheckoutSummaryComponent,
        title: 'Bestellübersicht',
        canDeactivate: [canDeactivateTabCleanup],
      },
      { path: '', pathMatch: 'full', redirectTo: 'review' },
    ],
  },
];

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