import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { CONSUMER_COMPLEXES_ROUTES } from './complexes';
import { CONSUMER_BUSINESS_ACTIVITY_GOODS_ROUTES } from './goods';

export type TConsumerBusinessActivityRouteNames = 'businessActivities' | 'businessActivity';

export const consumerBusinessActivityNamedRoutes: NamedRoutes<TConsumerBusinessActivityRouteNames> =
  {
    businessActivities: {
      path: 'business_activities',
      loadComponent: () =>
        import('../../views/list.component').then((m) => m.ConsumerBusinessActivitiesComponent),
      meta: {
        title: 'کسب‌و‌کارها',
        pagePath: () => '/consumer/business_activities',
      },
    },
    businessActivity: {
      path: 'business_activities/:businessActivityId',
      loadComponent: () =>
        import('../../views/single.component').then((m) => m.ConsumerBusinessActivityComponent),
      meta: {
        title: 'کسب‌و‌کار',
        pagePath: (businessActivityId: string) =>
          `/consumer/business_activities/${businessActivityId}`,
      },
    },
  };

export const CONSUMER_BUSINESS_ACTIVITIES_ROUTES: Routes = [
  consumerBusinessActivityNamedRoutes.businessActivities,
  {
    path: consumerBusinessActivityNamedRoutes.businessActivity.path,
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.BusinessActivityLayoutComponent),
    children: [
      {
        ...consumerBusinessActivityNamedRoutes.businessActivity,
        path: '',
      },
      ...CONSUMER_BUSINESS_ACTIVITY_GOODS_ROUTES,
      ...CONSUMER_COMPLEXES_ROUTES,
    ],
  },
];
