import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { CONSUMER_CUSTOMER_SALE_INVOICES_ROUTES } from './saleInvoices';

export type TConsumerCustomersRouteNames = 'customers' | 'customer';

export const consumerCustomersNamedRoutes: NamedRoutes<TConsumerCustomersRouteNames> = {
  customers: {
    path: 'customers',
    loadComponent: () =>
      import('../../views/list.component').then((m) => m.ConsumerCustomersComponent),
    meta: {
      title: 'مشتری‌ها',
      pagePath: () => 'consumer/customers',
    },
  },
  customer: {
    path: 'customers/:customerId',
    loadComponent: () =>
      import('../../views/single.component').then((m) => m.ConsumerCustomerComponent),
    meta: {
      title: 'مشتری',
      pagePath: (customerId: string) => `consumer/customers/${customerId}`,
    },
  },
};

export const CONSUMER_CUSTOMERS_ROUTES: Routes = [
  consumerCustomersNamedRoutes.customers,
  {
    path: consumerCustomersNamedRoutes.customer.path,
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.ConsumerCustomerLayoutComponent),
    children: [
      {
        ...consumerCustomersNamedRoutes.customer,
        path: '',
      },
      ...CONSUMER_CUSTOMER_SALE_INVOICES_ROUTES,
    ],
  },
];
