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

export type TConsumerAccountsRouteNames = 'accounts' | 'account';

export const consumerAccountsNamedRoutes: NamedRoutes<TConsumerAccountsRouteNames> = {
  accounts: {
    path: 'accounts',
    loadComponent: () =>
      import('../../views/list.component').then((m) => m.ConsumerAccountsComponent),
    meta: {
      title: 'حساب‌های کاربری',
      pagePath: () => '/consumer/accounts',
    },
  },
  account: {
    path: 'accounts/:accountId',
    loadComponent: () =>
      import('../../views/single.component').then((m) => m.ConsumerAccountComponent),
    meta: {
      title: 'حساب کاربری',
      pagePath: (accountId: string) => `/consumer/accounts/${accountId}`,
    },
  },
};

export const CONSUMER_ACCOUNTS_ROUTES: Routes = [
  consumerAccountsNamedRoutes.accounts,
  {
    path: consumerAccountsNamedRoutes.account.path,
    loadComponent: () =>
      import('../../components/layout.component').then((m) => m.ConsumerAccountLayoutComponent),
    children: [
      {
        ...consumerAccountsNamedRoutes.account,
        path: '',
      },
      ...CONSUMER_ACCOUNT_PERMISSIONS_ROUTES,
    ],
  },
];
