Skip to content
Snippets Groups Projects
app-routing.module.ts 6.18 KiB
Newer Older
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { NgModule } from '@angular/core';
import { Route, RouterModule, Routes } from '@angular/router';
import { CartoComponent } from './carto/carto.component';
import { ContactComponent } from './contact/contact.component';
import { FooterComponent } from './footer/footer.component';
import { StructureListPrintComponent } from './form/orientation-form/component/structure-list-print/structure-list-print.component';
import { OrientationFormComponent } from './form/orientation-form/orientation-form.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 { RoleGuard } from './guards/role.guard';
import { LegalNoticeComponent } from './legal-notice/legal-notice.component';
import { LoginComponent } from './login/login.component';
import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component';
import { PageComponent } from './page/page.component';
import { EditComponent } from './profile/edit/edit.component';
import { ResetEmailComponent } from './reset-email/reset-email.component';
import { ResetPasswordComponent } from './reset-password/reset-password.component';
import { StructureResolver } from './resolvers/structure.resolver';
import { TempUserResolver } from './resolvers/temp-user.resolver';
import { PasswordFormComponent } from './shared/components';
import { RouteRole } from './shared/enum/routeRole.enum';
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';

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,
    ],
    children: [
      {
        path: '',
        component: CartoComponent,
      },
      {
        path: '',
        outlet: 'left-pane',
        component: StructureDetailsComponent,
      },
    ],
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  },
  {
    path: 'login',
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',
  {
    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),
      },
      {
        path: 'edit',
        canActivate: [AuthGuard],
        component: EditComponent,
      },
      {
        path: '',
        outlet: 'left-pane',
        data: { fullScreen: true },
        component: StructureDetailsComponent,
      },
    children: [
      {
        path: '',
        canActivate: [AuthGuard],
        component: StructureJoinComponent,
      },
      footerOutletRoute,
    ],
  {
    path: 'join/:id',
    children: [
      {
        path: '',
        canActivate: [AuthGuard],
        component: StructureJoinComponent,
        resolve: {
          structure: StructureResolver,
        },
      },
    ],
  },
  {
    path: 'reset-password',
    children: [
      {
        path: '',
        component: ResetPasswordComponent,
      },
      footerOutletRoute,
    ],
  {
    path: 'new-password',
    component: PasswordFormComponent,
  },
    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: 'form',
    loadChildren: () => import('./form/form-view/form-view.module').then((m) => m.FormViewModule),
  },
  {
    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 {}