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

export type TPosesRouteNames = 'poses' | 'pos';

const baseUrl = (consumerId: string, businessId: string, complexId: string) =>
  `/partner/consumers/${consumerId}/business_activities/${businessId}/complexes/${complexId}/poses`;

export const partnerConsumerPosesNamedRoutes: NamedRoutes<TPosesRouteNames> = {
  poses: {
    path: 'poses',
    loadComponent: () =>
      import('../../views/poses/list.component').then((m) => m.PartnerUserPosesComponent),
    // @ts-ignore
    meta: {
      title: 'پایانه‌های فروش',
      pagePath: (consumerId: string, businessId: string, complexId: string) =>
        baseUrl(consumerId, businessId, complexId),
    },
  },
  pos: {
    path: 'poses/:posId',
    loadComponent: () =>
      import('../../views/poses/single.component').then((m) => m.PartnerUserPosComponent),
    // @ts-ignore
    meta: {
      title: 'پایانه فروش',
      pagePath: (consumerId: string, businessId: string, complexId: string, posId: string) =>
        `${baseUrl(consumerId, businessId, complexId)}/${posId}`,
    },
  },
};

export const PARTNER_CONSUMER_POSES_ROUTES: Routes = [
  partnerConsumerPosesNamedRoutes.poses,
  {
    path: partnerConsumerPosesNamedRoutes.pos.path,
    loadComponent: () =>
      import('../../components/poses/layout.component').then(
        (m) => m.PartnerConsumerPosLayoutComponent,
      ),
    children: [
      {
        path: '',
        loadComponent: partnerConsumerPosesNamedRoutes.pos.loadComponent,
      },
    ],
  },
];
