import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ProductListResolver } from '@fleio-api/billing/products/product-list.resolver';
import { ProductListComponent } from '@shared/common-components/billing/order/product-list/product-list.component';
import { OrderProductComponent } from './order-product/order-product.component';
import { OrderOptionsResolver } from '@fleio-api/billing/cart/order-options.resolver';
import { IRouteConfig } from '@shared/ui-api/interfaces/route-config/route-config';
import { SelectDomainComponent } from '@shared/common-tabs/billing/orders/select-domain/select-domain.component';
import { DomainOptionsComponent } from '@shared/common-tabs/billing/orders/domain-options/domain-options.component';
import { AuthGuard } from '@shared/auth/auth.guard';
import { OrderUnderReviewComponent } from './order-under-review/order-under-review.component';
import { ClientCreateOptionsResolver } from '@fleio-api/client-user/client/client-create-options.resolver';

const routes: Routes = [
  {
    path: '',
    component: ProductListComponent,
    canActivate: [AuthGuard],
    resolve: {
      products: ProductListResolver,
    },
    data: {
      config: {
        feature: 'billing.order'
      }
    }
  },
  {
    path: 'under-review',
    component: OrderUnderReviewComponent,
    canActivate:[AuthGuard],
    data: {
      config: {
        feature: 'billing.order',
        getBreadCrumbDetail: () => $localize`Order under review`,
      } as IRouteConfig,
    }
  },
  {
    path: 'order-product/:code',
    component: OrderProductComponent,
    canActivate: [AuthGuard],
    resolve: {
      orderOptions: OrderOptionsResolver,
    },
    data: {
      config: {
        feature: 'billing.order',
        getBreadCrumbDetail: (data) => $localize`Order ${data.orderOptions.name}`,
      } as IRouteConfig,
    }
  },
  {
    path: 'order-product/:code/:cycle',
    component: OrderProductComponent,
    canActivate: [AuthGuard],
    resolve: {
      orderOptions: OrderOptionsResolver,
    },
    data: {
      config: {
        feature: 'billing.order',
        getBreadCrumbDetail: (data) => $localize`Order ${data.orderOptions.name}`,
      } as IRouteConfig,
    }
  },
  {
    path: 'order-product/:code/:domain_action/:domain_name',
    component: OrderProductComponent,
    canActivate: [AuthGuard],
    resolve: {
      orderOptions: OrderOptionsResolver,
    },
    data: {
      config: {
        feature: 'billing.order',
        getBreadCrumbDetail: (data) => $localize`Order ${data.orderOptions.name}`,
      } as IRouteConfig,
    }
  },
  {
    path: 'select-domain/:code',
    component: SelectDomainComponent,
    canActivate: [AuthGuard],
    resolve: {
    },
    data: {
      config: {
        feature: 'plugins.domains',
        getBreadCrumbDetail: () => $localize`Select domain`,
      } as IRouteConfig,
    }
  },
  {
    path: 'domain-options/:cart_id/:domain_action/:domain_name',
    component: DomainOptionsComponent,
    canActivate: [AuthGuard],
    resolve: {
      clientCreateOptions: ClientCreateOptionsResolver,
    },
    data: {
      config: {
        feature: 'plugins.domains',
        getBreadCrumbDetail: () => $localize`Domain options`,
      } as IRouteConfig,
    }
  }
];

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