import { NgModule } from '@angular/core'; import { Route, RouterModule, Routes } from '@angular/router'; import { AnnuaireComponent } from './annuaire/annuaire.component'; import { CartoComponent } from './carto/carto.component'; import { ContactComponent } from './contact/contact.component'; import { FooterComponent } from './footer/footer.component'; import { AdminGuard } from './guards/admin.guard'; import { AuthGuard } from './guards/auth.guard'; import { ResetPasswordTokenGuard } from './guards/resetPasswordToken.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 { ResetEmailComponent } from './reset-email/reset-email.component'; import { ForgotPasswordComponent } from './reset-password/forgot-password.component'; import { StructureResolver } from './resolvers/structure.resolver'; import { StructureDetailsComponent } from './structure-list/components/structure-details/structure-details.component'; import { StructureListSearchPrintComponent } from './structure-list/components/structure-list-search-print/structure-list-search-print.component'; import { StructureListComponent } from './structure-list/structure-list.component'; import { StructureJoinComponent } from './structure/structure-join/structure-join.component'; const footerOutletRoute: Route = { path: '', outlet: 'footer', component: FooterComponent, }; function buildTitle(pageTitle = ''): string { let title = "Réseau des acteurs de l'inclusion numérique de la métropole de Lyon"; if (pageTitle) { title = pageTitle + ' | ' + title; } return title; } const routes: Routes = [ { path: 'print', outlet: 'print', children: [{ path: 'structures-search', component: StructureListSearchPrintComponent }], }, { path: 'acteurs', title: buildTitle('Cartographie'), children: [ { path: '', component: CartoComponent, }, { path: '', outlet: 'left-pane', component: StructureDetailsComponent, resolve: { structure: StructureResolver, }, }, ], }, { path: 'login', title: buildTitle('Connexion'), children: [ { path: '', component: LoginComponent, }, ], }, { path: 'structures', children: [ { path: '', component: StructureListComponent, }, footerOutletRoute, ], }, { path: 'legal-notice', title: buildTitle('Mentions légales'), children: [ { path: '', component: LegalNoticeComponent, }, footerOutletRoute, ], }, { path: 'page/:slugPage', title: buildTitle(), children: [ { path: '', component: PageComponent, }, footerOutletRoute, ], }, { path: 'contact', title: buildTitle('Contact'), children: [ { path: '', component: ContactComponent, }, footerOutletRoute, ], }, { path: 'users/verify/:id', children: [ { path: '', component: LoginComponent, }, ], }, { path: 'change-email/:id', children: [ { path: '', component: ResetEmailComponent, }, footerOutletRoute, ], }, { path: 'profile', title: buildTitle('Profil'), children: [ { path: '', canActivate: [AuthGuard], loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule), }, { path: '', outlet: 'left-pane', data: { fullScreen: true }, component: StructureDetailsComponent, resolve: { structure: StructureResolver, }, }, ], }, { path: 'join-request/:id', children: [ { path: '', canActivate: [AuthGuard], component: StructureJoinComponent, resolve: { structure: StructureResolver, }, }, ], }, { path: 'join-validation', children: [ { path: '', canActivate: [AuthGuard], component: StructureJoinComponent, resolve: { structure: StructureResolver, }, }, ], }, { path: 'reset-password', children: [ { path: '', canActivate: [ResetPasswordTokenGuard], component: ForgotPasswordComponent, }, ], }, { path: 'newsletter', title: buildTitle('Newsletter'), children: [ { path: '', component: NewsletterSubscriptionComponent, }, footerOutletRoute, ], }, { path: 'newsletter-unsubscribe', children: [ { path: '', component: NewsletterSubscriptionComponent, }, footerOutletRoute, ], }, { path: 'annuaire', title: buildTitle('Annuaire'), children: [ { path: '', component: AnnuaireComponent, }, footerOutletRoute, ], }, { path: 'news', title: buildTitle('Actualités'), children: [ { path: '', loadChildren: () => import('./post/post.module').then((m) => m.PostModule), }, footerOutletRoute, ], }, { path: 'admin', title: buildTitle('Admin'), children: [ { path: '', canActivate: [AdminGuard], loadChildren: () => import('./admin/admin.module').then((m) => m.AdminModule), }, ], }, { path: 'form', title: buildTitle(), loadChildren: () => import('./form/form-view/form-view.module').then((m) => m.FormViewModule), }, { path: 'orientation', title: buildTitle('Orientation'), children: [ { path: '', loadChildren: () => import('./form/orientation-form-view/orientation.module').then((m) => m.OrientationModule), }, { path: '', outlet: 'left-pane', data: { fullScreen: true, meeting: false }, component: StructureDetailsComponent, resolve: { structure: StructureResolver, }, }, ], }, { path: 'home', redirectTo: 'news', }, { path: '**', redirectTo: 'news', }, ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule], }) export class AppRoutingModule {}