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

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

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

export const superAdminConsumerPosesNamedRoutes: NamedRoutes<TPosesRouteNames> = {
  poses: {
    path: 'poses',
    loadComponent: () =>
      import('../../views/poses/list.component').then((m) => m.SuperAdminUserPosesComponent),
    // @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.SuperAdminUserPosComponent),
    // @ts-ignore
    meta: {
      title: 'پایانه فروش',
      pagePath: (consumerId: string, businessId: string, complexId: string, posId: string) =>
        `${baseUrl(consumerId, businessId, complexId)}/${posId}`,
    },
  },
};

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