import { Routes } from '@angular/router';
import { authGuard } from './core/auth/auth-guard';
import { rootRedirectGuard } from './core/auth/root-redirect-guard';
import { Shell } from './core/layout/shell/shell';

export const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    canActivate: [rootRedirectGuard],
    children: [],
  },
  {
    path: 'auth/login',
    loadComponent: () => import('./features/auth/login/login').then((m) => m.Login),
  },
  {
    path: 'auth/register',
    loadComponent: () => import('./features/auth/register/register').then((m) => m.Register),
  },
  {
    path: 'auth/forgot-password',
    loadComponent: () =>
      import('./features/auth/forgot-password/forgot-password').then((m) => m.ForgotPassword),
  },
  {
    path: 'auth/reset-password/:hash',
    loadComponent: () =>
      import('./features/auth/reset-password/reset-password').then((m) => m.ResetPassword),
  },
  {
    path: 'confirm-email/:hash',
    loadComponent: () =>
      import('./features/auth/confirm-email/confirm-email').then((m) => m.ConfirmEmail),
  },
  {
    path: 'password-change/:hash',
    loadComponent: () =>
      import('./features/auth/reset-password/reset-password').then((m) => m.ResetPassword),
  },
  {
    path: 'team-select',
    canActivate: [authGuard],
    loadComponent: () => import('./features/team-select/team-select').then((m) => m.TeamSelect),
  },
  {
    path: 'users',
    canActivate: [authGuard],
    loadComponent: () => import('./features/users/users').then((m) => m.Users),
  },
  {
    path: 't/:token/:playerId',
    loadComponent: () => import('./features/public-team/public-player').then((m) => m.PublicPlayer),
  },
  {
    path: 't/:token',
    loadComponent: () => import('./features/public-team/public-team').then((m) => m.PublicTeam),
  },
  {
    path: 'team/:id',
    canActivate: [authGuard],
    component: Shell,
    children: [
      { path: '', pathMatch: 'full', redirectTo: 'overview' },
      {
        path: 'overview',
        loadComponent: () => import('./features/team/overview/overview').then((m) => m.Overview),
      },
      {
        path: 'members',
        loadComponent: () => import('./features/team/members/members').then((m) => m.Members),
      },
      {
        path: 'members/:playerId',
        loadComponent: () =>
          import('./features/team/members/player-detail').then((m) => m.PlayerDetail),
      },
      {
        path: 'cashbox',
        loadComponent: () => import('./features/team/cashbox/cashbox').then((m) => m.Cashbox),
      },
      {
        path: 'more',
        loadComponent: () => import('./features/team/more/more').then((m) => m.More),
      },
      {
        path: 'more/penalties',
        loadComponent: () =>
          import('./features/team/more/penalties/penalties').then((m) => m.Penalties),
      },
      {
        path: 'more/recurring-transactions',
        loadComponent: () =>
          import('./features/team/more/recurring-transactions/recurring-transactions').then(
            (m) => m.RecurringTransactions,
          ),
      },
      {
        path: 'more/invite',
        loadComponent: () => import('./features/team/more/invite/invite').then((m) => m.Invite),
      },
      {
        path: 'more/profile',
        loadComponent: () => import('./features/team/more/profile/profile').then((m) => m.Profile),
      },
      {
        path: 'more/public-access',
        loadComponent: () =>
          import('./features/team/more/public-access/public-access').then((m) => m.PublicAccess),
      },
      {
        path: 'more/permissions',
        loadComponent: () =>
          import('./features/team/more/permissions/permissions').then((m) => m.Permissions),
      },
      {
        path: 'more/guide',
        loadComponent: () =>
          import('./features/team/more/guide/guide').then((m) => m.Guide),
      },
    ],
  },
  {
    path: '**',
    loadComponent: () => import('./core/layout/not-found/not-found').then((m) => m.NotFound),
  },
];
