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

export type TPosGoodsManagementRouteNames = 'goods' | 'update' | 'create';

const baseRoute = `${config.isPosApplication ? '' : '/pos'}/goods`;

export const PosGoodsManagementRoutes: NamedRoutes<TPosGoodsManagementRouteNames> = {
  goods: {
    path: 'goods',
    loadComponent: () =>
      import('../../views/list.component').then((m) => m.PosGoodsManagementListComponent),
    meta: {
      title: 'مدیریت کالاها',
      pagePath: () => baseRoute,
    },
  },
  update: {
    path: 'goods/:goodId',
    loadComponent: () =>
      import('../../views/update.component').then((m) => m.PosGoodsUpdateComponent),
    meta: {
      title: 'ویرایش کالا',
      pagePath: (goodId: string) => `${baseRoute}/${goodId}`,
    },
  },
  create: {
    path: 'goods/create',
    loadComponent: () =>
      import('../../views/create.component').then((m) => m.PosGoodsCreateComponent),
    meta: {
      title: 'ایجاد کالا',
      pagePath: () => baseRoute,
    },
  },
};

export const POS_GOODS_MANAGEMENT_ROUTES: Routes = [
  PosGoodsManagementRoutes.goods,
  PosGoodsManagementRoutes.create,
  PosGoodsManagementRoutes.update,
];
