import { Routes } from '@angular/router';
import { authGuard, guestGuard, adminGuard } from '@core/guards/auth.guard';

export const routes: Routes = [
  { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
  {
    path: 'dashboard',
    loadComponent: () =>
      import('@features/dashboard/pages/student-dashboard/student-dashboard.component')
        .then(m => m.StudentDashboardComponent),
    canActivate: [authGuard],
  },
  {
    path: 'login',
    loadComponent: () =>
      import('@features/auth/pages/login/login.component')
        .then(m => m.LoginComponent),
    canActivate: [guestGuard],
  },
  {
    path: 'register',
    loadComponent: () =>
      import('@features/auth/pages/register/register.component')
        .then(m => m.RegisterComponent),
    canActivate: [guestGuard],
  },
  {
    path: 'reset-password',
    loadComponent: () =>
      import('@features/auth/pages/reset-password/reset-password.component')
        .then(m => m.ResetPasswordComponent),
    canActivate: [guestGuard],
  },
  {
    path: 'students',
    loadComponent: () =>
      import('@features/students/pages/student-list/student-list.component')
        .then(m => m.StudentListComponent),
    canActivate: [authGuard, adminGuard],
  },
  {
    path: 'students/new',
    loadComponent: () =>
      import('@features/students/pages/student-form/student-form.component')
        .then(m => m.StudentFormComponent),
    canActivate: [authGuard, adminGuard],
  },
  {
    path: 'students/:id/edit',
    loadComponent: () =>
      import('@features/students/pages/student-form/student-form.component')
        .then(m => m.StudentFormComponent),
    canActivate: [authGuard, adminGuard],
  },
  {
    path: 'enrollment/:studentId',
    loadComponent: () =>
      import('@features/enrollment/pages/enrollment-page/enrollment-page.component')
        .then(m => m.EnrollmentPageComponent),
    canActivate: [authGuard],
  },
  {
    path: 'classmates/:studentId',
    loadComponent: () =>
      import('@features/classmates/pages/classmates-page/classmates-page.component')
        .then(m => m.ClassmatesPageComponent),
    canActivate: [authGuard],
  },
  { path: '**', redirectTo: 'login' },
];
