import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { GUILD_GOOD_CATEGORIES_ROUTES } from './goodCategories';
import { GUILD_GOODS_ROUTES } from './goods';
import { GUILD_STOCK_KEEPING_UNITS_ROUTES } from './stockKeepingUnits';

export type TGuildsRouteNames = 'guilds' | 'guild';

export const guildsNamedRoutes: NamedRoutes<TGuildsRouteNames> = {
  guilds: {
    path: 'guilds',
    loadComponent: () => import('../../views/list.component').then((m) => m.GuildsComponent),
    meta: {
      title: 'اصناف',
      pagePath: () => '/super_admin/guilds',
    },
  },
  guild: {
    path: 'guilds/:guildId',
    loadComponent: () => import('../../views/single.component').then((m) => m.GuildComponent),
    // @ts-ignore
    meta: {
      title: 'صنف',
      pagePath: (guildId: string) => `/super_admin/guilds/${guildId}`,
    },
  },
};

export const GUILDS_ROUTES: Routes = [
  guildsNamedRoutes.guilds,
  {
    path: 'guilds/:guildId',
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.GuildLayoutComponent),

    children: [
      {
        path: '',
        loadComponent: () => import('../../views/single.component').then((m) => m.GuildComponent),
      },

      ...GUILD_GOOD_CATEGORIES_ROUTES,
      ...GUILD_GOODS_ROUTES,
      ...GUILD_STOCK_KEEPING_UNITS_ROUTES,

      // {
      //   path: 'good_categories/:categoryId',
      //   loadComponent: () => import('../../views/categories/').then((m) => m.GuildComponent),
      //   // @ts-ignore
      //   meta: {
      //     title: 'دسته‌بندی‌ کالا',
      //   },
      // },
    ],
  },
];
