Skip to content
Snippets Groups Projects
app-routing.module.ts 4 KiB
Newer Older
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PageComponent } from './page/page.component';
import { ContactComponent } from './contact/contact.component';
import { FormComponent } from './form/structure-form/form.component';
import { AdminGuard } from './guards/admin.guard';
import { AuthGuard } from './guards/auth.guard';
import { DeactivateGuard } from './guards/deactivate.guard';
import { CartoComponent } from './carto/carto.component';
import { LegalNoticeComponent } from './legal-notice/legal-notice.component';
import { ResetEmailComponent } from './reset-email/reset-email.component';
import { ResetPasswordComponent } from './reset-password/reset-password.component';
import { TempUserResolver } from './resolvers/temp-user.resolver';
import { StructureJoinComponent } from './structure-join/structure-join.component';
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { StructureDetailsComponent } from './structure-list/components/structure-details/structure-details.component';
import { StructureListComponent } from './structure-list/structure-list.component';
import { UserVerificationComponent } from './user-verification/user-verification.component';
import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component';
import { OrientationFormComponent } from './form/orientation-form/orientation-form.component';
import { StructureListPrintComponent } from './form/orientation-form/component/structure-list-print/structure-list-print.component';
import { StructureResolver } from './resolvers/structure.resolver';
import { RoleGuard } from './guards/role.guard';
import { RouteRole } from './shared/enum/routeRole.enum';
Hugo SUBTIL's avatar
Hugo SUBTIL committed

const routes: Routes = [
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  { path: 'print', outlet: 'print', children: [{ path: 'structure', component: StructureDetailsComponent }] },
  { path: 'print', outlet: 'print', children: [{ path: 'structures', component: StructureListPrintComponent }] },
  {
    path: 'orientation',
    component: OrientationFormComponent,
  },
    path: 'acteurs',
    component: CartoComponent,
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  },
  {
    path: 'login',
    component: CartoComponent,
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  },
  {
    path: 'structures',
Hugo SUBTIL's avatar
Hugo SUBTIL committed
    component: StructureListComponent,
  },
  {
    path: 'legal-notice',
    component: LegalNoticeComponent,
  },
  {
    path: 'page/:slugPage',
    component: PageComponent,
  {
    path: 'contact',
    component: ContactComponent,
  },
  {
    path: 'users/verify/:id',
    component: UserVerificationComponent,
  },
  {
    path: 'register',
    component: FormComponent,
    canDeactivate: [DeactivateGuard],
    resolve: {
      user: TempUserResolver,
    },
  },
  {
    path: 'change-email/:id',
    component: ResetEmailComponent,
  },
  {
    path: 'profile',
    canActivate: [AuthGuard],
    loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule),
  {
    path: 'join',
    canActivate: [AuthGuard],
    component: StructureJoinComponent,
  },
  {
    path: 'reset-password',
    component: ResetPasswordComponent,
  },
  {
    path: 'create-structure',
    component: FormComponent,
    canDeactivate: [DeactivateGuard],
  {
    path: 'create-structure/:id',
    component: FormComponent,
    canDeactivate: [DeactivateGuard],
    canActivate: [RoleGuard],
    data: { allowedRoles: [RouteRole.structureAdmin] },
    resolve: {
      structure: StructureResolver,
    },
  },
  {
    path: 'newsletter',
    component: NewsletterSubscriptionComponent,
  },

  {
    path: 'newsletter-unsubscribe',
    component: NewsletterSubscriptionComponent,
  },

Hugo SUBTIL's avatar
Hugo SUBTIL committed
    path: 'news',
Jérémie BRISON's avatar
Jérémie BRISON committed
    loadChildren: () => import('./post/post.module').then((m) => m.PostModule),
  {
    path: 'admin',
    canActivate: [AdminGuard],
    loadChildren: () => import('./admin/admin.module').then((m) => m.AdminModule),
  },
  {
    path: 'home',
    redirectTo: 'news',
  },
    redirectTo: 'news',
Hugo SUBTIL's avatar
Hugo SUBTIL committed

@NgModule({
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
  exports: [RouterModule],
Hugo SUBTIL's avatar
Hugo SUBTIL committed
})
export class AppRoutingModule {}