import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';

import { ListarUsuariosComponent } from './Adminstradores/CrudUsuarios/listar-usuarios/listar-usuarios.component';
import { InserirUsuarioComponent } from './Adminstradores/CrudUsuarios/inserir-usuarios/inserir-usuarios.component';
import { EditarUsuarioComponent } from './Adminstradores/CrudUsuarios/editar-usuarios/editar-usuarios.component';
import { DashboardUsuarioComponent } from './Funcionario/DashboardUsuario/dashboardUsuario.component';
import { ListarMaterialComponent } from './Adminstradores/CrudMaterialdeApoio/listar-material/listar-material.component';
import { InserirMaterialComponent } from './Adminstradores/CrudMaterialdeApoio/inserir-material/inserir-material.component';
import { EditarMaterialComponent } from './Adminstradores/CrudMaterialdeApoio/editar-material/editar-material.component';
import { ListarQuestionarioComponent } from './Adminstradores/CrudQuetionarios/listar-questionario/listar-questionario.component';
import { InserirQuestionarioComponent } from './Adminstradores/CrudQuetionarios/inserir-questionario/inserir-questionario.component';
import { EditarQuestionarioComponent } from './Adminstradores/CrudQuetionarios/editar-questionario/editar-questionario.component';
import { DashboardAdminComponent } from './Adminstradores/dashboard-admin/dashboard-admin.component';
import { HistoricoComponent } from './Funcionario/Historico/historico.component';
import { MaterialFuncionarioComponent } from './Funcionario/MaterialDeApoio/materialFuncionario.component';
import { ListarQuestionariosComponent } from './Funcionario/Questionario/listarQuestionarios/listarQuestionario.component';
import { ResponderQuestionarioComponent } from './Funcionario/Questionario/responderQuestionarios/responderQuestionario.component';
import { LoginComponent } from './Cadastro/login/login.component';
import { RecuperarSenhaComponent } from './Cadastro/recuperar-senha/recuperar-senha.component';
import { RelatoriosComponent } from './Adminstradores/relatorios/relatorios.component';
import { CadastroNovaSenhaComponent } from './Cadastro/cadastro-nova-senha/cadastro-nova-senha.component';
import { authGuard } from './auth.guard';

export const routes: Routes = [
  {path: '', redirectTo: 'login', pathMatch: 'full'},
  {path: 'login', component: LoginComponent, pathMatch: 'full'},
  {path: 'login/recuperar', component: RecuperarSenhaComponent, pathMatch: 'full'},
  {path: 'login/nova-senha', component: CadastroNovaSenhaComponent, pathMatch: 'full'},

  // Sessao Admin
  {
    path: 'usuarios',
    component: ListarUsuariosComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'usuarios/novo',
    component: InserirUsuarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'usuarios/editar/:id',
    component: EditarUsuarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'material',
    component: ListarMaterialComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'material/novo',
    component: InserirMaterialComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'material/editar/:id',
    component: EditarMaterialComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'questionario',
    component: ListarQuestionarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'questionario/novo',
    component: InserirQuestionarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'questionario/editar/:id',
    component: EditarQuestionarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'dashboardadmin',
    component: DashboardAdminComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },
  {
    path: 'relatorios',
    component: RelatoriosComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['ADM']}
  },


  // Sessao Funcionario
  {
    path: 'dashboardusuario',
    component: DashboardUsuarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['FUNC']}
  },
  {
    path: 'historico',
    component: HistoricoComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['FUNC']}
  },
  {
    path: 'materialfuncionario',
    component: MaterialFuncionarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['FUNC']}
  },
  {
    path: 'listar',
    component: ListarQuestionariosComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['FUNC']}
  },
  {
    path: 'responder',
    component: ResponderQuestionarioComponent,
    pathMatch: 'full',
    canActivate: [authGuard],
    data: {roles:['FUNC']}
  },
  {path:'**', redirectTo:'dashboardusuario'}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule{}