import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import { SUPER_ADMIN_CONSUMER_BUSINESS_ACTIVITIES_ROUTES } from '../../../consumers/constants/routes/businessActivities';
import { SUPER_ADMIN_USER_ACCOUNTS_ROUTES } from './accounts';

export type TUsersRouteNames = 'users' | 'user';

export const usersNamedRoutes: NamedRoutes<TUsersRouteNames> = {
  users: {
    path: 'users',
    loadComponent: () => import('../../views/list.component').then((m) => m.UsersComponent),
    meta: {
      title: 'کاربران',
      pagePath: () => '/super_admin/users',
    },
  },
  user: {
    path: 'users/:userId',
    loadComponent: () => import('../../views/single.component').then((m) => m.UserComponent),
    meta: {
      title: 'کاربر',
      pagePath: (userId: string) => `/super_admin/users/${userId}`,
    },
  },
};

export const USERS_ROUTES: Routes = [
  usersNamedRoutes.users,
  {
    path: usersNamedRoutes.user.path,
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.UserLayoutComponent),
    children: [
      {
        path: '',
        loadComponent: usersNamedRoutes.user.loadComponent,
      },
      ...SUPER_ADMIN_USER_ACCOUNTS_ROUTES,
      ...SUPER_ADMIN_CONSUMER_BUSINESS_ACTIVITIES_ROUTES,
    ],
  },
];
