import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { PARTNER_CONSUMER_COMPLEXES_ROUTES } from './complexes';

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

export const partnerConsumerBusinessActivitiesNamedRoutes: NamedRoutes<TBusinessActivitiesRouteNames> =
  {
    businessActivities: {
      path: 'business_activities',
      loadComponent: () =>
        import('../../views/businessActivities/list.component').then(
          (m) => m.PartnerUserBusinessActivitiesComponent,
        ),
      // @ts-ignore
      meta: {
        title: 'فعالیت اقتصادی',
        pagePath: (consumerId: string) => `/partner/consumers/${consumerId}/business_activities`,
      },
    },
    businessActivity: {
      path: 'business_activities/:businessActivityId',
      loadComponent: () =>
        import('../../views/businessActivities/single.component').then(
          (m) => m.PartnerUserBusinessActivityComponent,
        ),
      // @ts-ignore
      meta: {
        title: 'فعالیت اقتصادی',
        pagePath: (consumerId: string, businessId: string) =>
          `/partner/consumers/${consumerId}/business_activities/${businessId}`,
      },
    },
  };

export const PARTNER_CONSUMER_BUSINESS_ACTIVITIES_ROUTES: Routes = [
  partnerConsumerBusinessActivitiesNamedRoutes.businessActivities,
  {
    path: partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.path,
    loadComponent: () =>
      import('../../components/businessActivities/layout.component').then(
        (m) => m.PartnerUserBusinessActivityLayoutComponent,
      ),
    children: [
      {
        path: '',
        loadComponent: partnerConsumerBusinessActivitiesNamedRoutes.businessActivity.loadComponent,
      },
      ...PARTNER_CONSUMER_COMPLEXES_ROUTES,
    ],
  },
];
