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

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

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

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

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