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

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

const baseUrl = `/consumer/poses`;

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

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