Skip to content
Snippets Groups Projects
app-routing.module.ts 5.82 KiB
Newer Older
  • Learn to ignore specific revisions
  • Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    import { NgModule } from '@angular/core';
    
    import { Routes, RouterModule, Route } 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';
    
    import { FooterComponent } from './footer/footer.component';
    
    const footerOutletRoute: Route = {
      path: '',
      outlet: 'footer',
      component: FooterComponent,
    };
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    
    
    const routes: Routes = [
    
      {
        path: 'print',
        outlet: 'print',
        children: [{ path: 'structure', component: StructureDetailsComponent }, footerOutletRoute],
      },
      {
        path: 'print',
        outlet: 'print',
        children: [{ path: 'structures', component: StructureListPrintComponent }, footerOutletRoute],
      },
    
      {
        path: 'orientation',
    
        children: [
          {
            path: '',
            component: OrientationFormComponent,
          },
          footerOutletRoute,
        ],
    
        path: 'acteurs',
        component: CartoComponent,
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      },
      {
        path: 'login',
    
        children: [
          {
            path: '',
            component: CartoComponent,
          },
          footerOutletRoute,
        ],
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      },
      {
    
        path: 'structures',
    
        children: [
          {
            path: '',
            component: StructureListComponent,
          },
          footerOutletRoute,
        ],
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      },
    
      {
        path: 'legal-notice',
    
        children: [
          {
            path: '',
            component: LegalNoticeComponent,
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            component: PageComponent,
          },
          footerOutletRoute,
        ],
    
      {
        path: 'contact',
    
        children: [
          {
            path: '',
            component: ContactComponent,
          },
          footerOutletRoute,
        ],
    
      {
        path: 'users/verify/:id',
    
        children: [
          {
            path: '',
            component: UserVerificationComponent,
          },
          footerOutletRoute,
        ],
    
      {
        path: 'register',
    
        children: [
          {
            path: '',
            component: FormComponent,
            canDeactivate: [DeactivateGuard],
            resolve: {
              user: TempUserResolver,
            },
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            component: ResetEmailComponent,
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            canActivate: [AuthGuard],
            loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule),
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            canActivate: [AuthGuard],
            component: StructureJoinComponent,
          },
          footerOutletRoute,
        ],
    
      {
        path: 'reset-password',
    
        children: [
          {
            path: '',
            component: ResetPasswordComponent,
          },
          footerOutletRoute,
        ],
    
      {
        path: 'create-structure',
    
        children: [
          {
            path: '',
            component: FormComponent,
            canDeactivate: [DeactivateGuard],
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            component: FormComponent,
            canDeactivate: [DeactivateGuard],
            canActivate: [RoleGuard],
            data: { allowedRoles: [RouteRole.structureAdmin] },
            resolve: {
              structure: StructureResolver,
            },
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            component: NewsletterSubscriptionComponent,
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            component: NewsletterSubscriptionComponent,
          },
          footerOutletRoute,
        ],
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        path: 'news',
    
        children: [
          {
            path: '',
            loadChildren: () => import('./post/post.module').then((m) => m.PostModule),
          },
          footerOutletRoute,
        ],
    
        children: [
          {
            path: '',
            canActivate: [AdminGuard],
            loadChildren: () => import('./admin/admin.module').then((m) => m.AdminModule),
          },
          footerOutletRoute,
        ],
    
      {
        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 {}