import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { PARTNER_CONSUMER_ACCOUNTS_ROUTES } from './accounts';
import { PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES } from './businessActivities';

export type TConsumersRouteNames = 'consumers' | 'consumer';

export const partnerConsumersNamedRoutes: NamedRoutes<TConsumersRouteNames> = {
  consumers: {
    path: 'consumers',
    loadComponent: () => import('../../views/list.component').then((m) => m.ConsumersComponent),
    meta: {
      title: 'مشتری‌ها',
      pagePath: () => '/partner/consumers',
    },
  },
  consumer: {
    path: 'consumers/:consumerId',
    loadComponent: () => import('../../views/single.component').then((m) => m.ConsumerComponent),
    meta: {
      title: 'مشتری',
      pagePath: (guildId: string) => `/partner/consumers/${guildId}`,
    },
  },
};

export const PARTNER_CONSUMERS_ROUTES: Routes = [
  partnerConsumersNamedRoutes.consumers,
  {
    path: 'consumers/:consumerId',
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.ConsumerLayoutComponent),

    children: [
      {
        path: '',
        loadComponent: () =>
          import('../../views/single.component').then((m) => m.ConsumerComponent),
      },
      ...PARTNER_CONSUMER_ACCOUNTS_ROUTES,
      ...PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES,
    ],
  },
];
