diff --git a/src/app/admin/components/deleted-structures/deleted-structures.component.ts b/src/app/admin/components/deleted-structures/deleted-structures.component.ts index 03da0fb9dded8bcc64b63f4dfec9a2ea4207caa5..2ef8c559414ce2a2aa2bfacf385ba699ef802125 100644 --- a/src/app/admin/components/deleted-structures/deleted-structures.component.ts +++ b/src/app/admin/components/deleted-structures/deleted-structures.component.ts @@ -65,7 +65,7 @@ export class DeletedStructuresComponent implements OnInit { } private renderLink(structure: Structure): string { - return `<a href="/acteurs?id=${structure._id}" target="_blank">${structure.structureName}</a>`; + return `<a href="/acteurs?structure=${structure.permalink}" target="_blank">${structure.structureName}</a>`; } private restoreStructure(structureId: string): void { diff --git a/src/app/admin/components/manage-users/administred-structures/administred-structures.component.html b/src/app/admin/components/manage-users/administred-structures/administred-structures.component.html index 1b32cce769e415c95fdb35fa28603cc5dc00ced0..cb937d29dc1f1341100532509d087c2074ca2e16 100644 --- a/src/app/admin/components/manage-users/administred-structures/administred-structures.component.html +++ b/src/app/admin/components/manage-users/administred-structures/administred-structures.component.html @@ -1,5 +1,7 @@ <div *ngIf="structures.data.structures && structures.data.structures.length !== 0"> <p *ngFor="let structure of structures.data.structures"> - <a *ngIf="structure" target="_blank" href="/acteurs?id={{ structure._id }}">{{ structure.structureName }}</a> + <a *ngIf="structure" target="_blank" href="/acteurs?structure={{ structure.permalink }}">{{ + structure.structureName + }}</a> </p> </div> diff --git a/src/app/admin/components/structures-list/admin-structures-list.component.ts b/src/app/admin/components/structures-list/admin-structures-list.component.ts index dca6de719d96405f0cee9ce99b49e8e0e2a05ee6..3342277bf451b8266a96f729746a621abff88996 100644 --- a/src/app/admin/components/structures-list/admin-structures-list.component.ts +++ b/src/app/admin/components/structures-list/admin-structures-list.component.ts @@ -1,6 +1,5 @@ import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; import { ColDef } from 'ag-grid-community'; import { finalize } from 'rxjs/operators'; import { AdminStructure } from '../../models/adminStructureList.interface'; @@ -15,7 +14,6 @@ export class AdminStructuresListComponent implements OnInit { constructor( private adminService: AdminService, private datePipe: DatePipe, - private router: Router, ) {} public structuresClaimed: AdminStructure[]; public structuresInClaim: AdminStructure[]; @@ -28,7 +26,7 @@ export class AdminStructuresListComponent implements OnInit { public columnDefs: ColDef<AdminStructure>[] = [ { headerName: 'Structure', - cellRenderer: (params): string => this.renderLink(params.data.structureId, params.data.structureName), + cellRenderer: (params): string => this.renderLink(params.data), comparator(_, __, nodeA, nodeB): number { return nodeA.data.structureName.toLowerCase() > nodeB.data.structureName.toLocaleLowerCase() ? -1 : 1; }, @@ -59,7 +57,7 @@ export class AdminStructuresListComponent implements OnInit { }); } - private renderLink(structureId: string, structureName: string): string { - return `<a href="/acteurs?id=${structureId}" target="_blank">${structureName}</a>`; + private renderLink(structure: AdminStructure): string { + return `<a href="/acteurs?structure=${structure.permalink}" target="_blank">${structure.structureName}</a>`; } } diff --git a/src/app/admin/models/adminStructureList.interface.ts b/src/app/admin/models/adminStructureList.interface.ts index 9a751bbb62934c98b82d0075dfe189f1fd8473b7..8229ee48918e561ea36251988093b56b9db28b64 100644 --- a/src/app/admin/models/adminStructureList.interface.ts +++ b/src/app/admin/models/adminStructureList.interface.ts @@ -10,4 +10,5 @@ export interface AdminStructure { structureName: string; updatedAt: Date; isOutdated: boolean; + permalink: string; } diff --git a/src/app/annuaire/result-list/result-list.component.ts b/src/app/annuaire/result-list/result-list.component.ts index 152027e06beca7af38d8b4537cb855e790b65248..fd7d3f431d93adacaea82105eeb93b48899bc4a4 100644 --- a/src/app/annuaire/result-list/result-list.component.ts +++ b/src/app/annuaire/result-list/result-list.component.ts @@ -53,14 +53,11 @@ export class ResultListComponent implements OnChanges, AfterViewInit { }, 0); } } - public goToUser(userId: string): void { - this.router.navigateByUrl(`/profile/${userId}`); - } public goLogin(): void { - this.router.navigate(['/login'], { queryParams: { returnUrl: '/annuaire' } }); + this.router.navigate(['/connexion'], { queryParams: { returnUrl: '/annuaire' } }); } public goRegister(): void { - this.router.navigateByUrl('/form/account'); + this.router.navigateByUrl('/formulaire/compte'); } public resetFilters(): void { this.resetEvent.emit(); diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5e92142b2286d826abef4f8b61c6abcb9fa7af51..b9bc19160a6d9ed49ce7edc07e362756ed91dd14 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -42,6 +42,10 @@ const routes: Routes = [ { path: 'acteurs', title: buildTitle('Cartographie'), + runGuardsAndResolvers: 'always', + resolve: { + structure: StructureResolver, + }, children: [ { path: '', @@ -51,14 +55,11 @@ const routes: Routes = [ path: '', outlet: 'left-pane', component: StructureDetailsComponent, - resolve: { - structure: StructureResolver, - }, }, ], }, { - path: 'login', + path: 'connexion', title: buildTitle('Connexion'), children: [ { @@ -78,7 +79,7 @@ const routes: Routes = [ ], }, { - path: 'legal-notice', + path: 'mentions-legales', title: buildTitle('Mentions légales'), children: [ { @@ -130,7 +131,7 @@ const routes: Routes = [ ], }, { - path: 'profile', + path: 'profil', title: buildTitle('Profil'), children: [ { @@ -142,6 +143,7 @@ const routes: Routes = [ path: '', outlet: 'left-pane', data: { fullScreen: true }, + runGuardsAndResolvers: 'always', component: StructureDetailsComponent, resolve: { structure: StructureResolver, @@ -150,7 +152,7 @@ const routes: Routes = [ ], }, { - path: 'join-request/:id', + path: 'join-request/:permalink', children: [ { path: '', @@ -176,7 +178,7 @@ const routes: Routes = [ ], }, { - path: 'reset-password', + path: 'mot-de-passe-oublie', children: [ { path: '', @@ -197,7 +199,7 @@ const routes: Routes = [ ], }, { - path: 'newsletter-unsubscribe', + path: 'desabonnement-newsletter', children: [ { path: '', @@ -218,7 +220,7 @@ const routes: Routes = [ ], }, { - path: 'news', + path: 'actualites', title: buildTitle('Actualités'), children: [ { @@ -240,13 +242,17 @@ const routes: Routes = [ ], }, { - path: 'form', + path: 'formulaire', title: buildTitle(), loadChildren: () => import('./form/form-view/form-view.module').then((m) => m.FormViewModule), }, { path: 'orientation', title: buildTitle('Orientation'), + runGuardsAndResolvers: 'always', + resolve: { + structure: StructureResolver, + }, children: [ { path: '', @@ -257,19 +263,16 @@ const routes: Routes = [ outlet: 'left-pane', data: { fullScreen: true, meeting: false }, component: StructureDetailsComponent, - resolve: { - structure: StructureResolver, - }, }, ], }, { path: 'home', - redirectTo: 'news', + redirectTo: 'actualites', }, { path: '**', - redirectTo: 'news', + redirectTo: 'actualites', }, ]; diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 54c79feabd5519c46b8c8b29fedd7d86caf3b861..e0a9b8048e53b0bea28995160e1d03ce850bea3d 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -56,9 +56,11 @@ export class CartoComponent implements OnInit { } } - if (history.state.data) { - this.currentStructure = new Structure(history.state.data); - } + this.activatedRoute.data.subscribe((data) => { + if (data.structure) { + this.currentStructure = new Structure(data.structure); + } + }); this.meta.updateTag({ name: 'description', diff --git a/src/app/footer/footer.component.html b/src/app/footer/footer.component.html index 358806c4bd7cde2478e982a69243de8f71b63880..abb538aad05089a294996511249072da991247c2 100644 --- a/src/app/footer/footer.component.html +++ b/src/app/footer/footer.component.html @@ -1,6 +1,6 @@ <footer class="footer"> <div class="links"> - <a class="clickable text-align-center" routerLink="/legal-notice" i18n>Mentions légales</a> + <a class="clickable text-align-center" routerLink="/mentions-legales" i18n>Mentions légales</a> <a class="clickable text-align-center" routerLink="/newsletter" i18n>Newsletter</a> <a class="clickable text-align-center" routerLink="/contact" i18n>Contact</a> <a class="clickable text-align-center" routerLink="/page/qui-sommes-nous" i18n>Qui sommes-nous ?</a> diff --git a/src/app/form/footer-form/footer-form.component.ts b/src/app/form/footer-form/footer-form.component.ts index e9dbe8ff9b9e2a4767241b4b362abc93bb847a3b..daf0dea0ad4d2b218fb9ef5ae412e899b34b7261 100644 --- a/src/app/form/footer-form/footer-form.component.ts +++ b/src/app/form/footer-form/footer-form.component.ts @@ -61,7 +61,7 @@ export class FooterFormComponent { } public goToProfile(): void { - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } /** diff --git a/src/app/form/form-view/form-view-routing.module.ts b/src/app/form/form-view/form-view-routing.module.ts index 73f5ba2d1cafe3bff6f4b3676dff64d2bf319f08..73a3a4cde91d2bda64ab887a40c35913b23f34d1 100644 --- a/src/app/form/form-view/form-view-routing.module.ts +++ b/src/app/form/form-view/form-view-routing.module.ts @@ -15,7 +15,7 @@ import { StructureFormComponent } from './structure-form/structure-form.componen const routes: Routes = [ { - path: 'structure/:id/:step', + path: 'structure/:permalink/:step', component: FormViewComponent, canActivate: [RoleGuard], data: { allowedRoles: [RouteRole.structureAdmin] }, @@ -24,7 +24,7 @@ const routes: Routes = [ }, }, { - path: 'register/:id', + path: 'inscription/:id', component: FormViewComponent, canDeactivate: [DeactivateGuard], resolve: { @@ -42,22 +42,22 @@ const routes: Routes = [ component: StructureFormComponent, }, { - path: 'profile', + path: 'profil', canActivate: [AuthGuard], component: ProfileFormComponent, }, { - path: 'personaloffer', + path: 'offre-personnelle', canActivate: [AuthGuard, PersonalOfferGuard], component: PersonalOfferFormComponent, }, { - path: 'account', + path: 'compte', component: AccountFormComponent, }, { path: '**', - redirectTo: 'account', + redirectTo: 'compte', }, ], }, diff --git a/src/app/form/form-view/form-view.component.html b/src/app/form/form-view/form-view.component.html index a4ee5a09ab8cddc00b8586d049b8f221a6af7f3f..052a59bcb1fd6c40ec8745751c4d4eefa88cb213 100644 --- a/src/app/form/form-view/form-view.component.html +++ b/src/app/form/form-view/form-view.component.html @@ -18,7 +18,7 @@ /> <div class="page"> <app-account-form - *ngIf="formType[routeParam] === formType.account || formType[this.routeParam] === formType.register" + *ngIf="routeParam === formTypeParam.account || routeParam === formTypeParam.register" [nbSteps]="nbSteps" [accountForm]="accountForm" [currentStep]="currentPage" @@ -27,7 +27,7 @@ (pageValid)="validatePage($event)" /> <app-profile-form - *ngIf="formType[routeParam] === formType.profile" + *ngIf="routeParam === formTypeParam.profile" [nbSteps]="nbSteps" [profileForm]="profileForm" [currentStep]="currentPage" @@ -35,7 +35,7 @@ (pageValid)="validatePage($event)" /> <app-structure-form - *ngIf="formType[routeParam] === formType.structure" + *ngIf="routeParam === formTypeParam.structure" [nbSteps]="nbSteps" [structure]="structure" [structureForm]="structureForm" @@ -48,7 +48,7 @@ (setEditStep)="setCurrentStep($event)" /> <app-personal-offer-form - *ngIf="formType[routeParam] === formType.personaloffer && structure" + *ngIf="routeParam === formTypeParam.personaloffer && structure" [nbSteps]="nbSteps" [personalOfferForm]="personalOfferForm" [currentStep]="currentPage" diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index 7cff6e41f11fa8918cc76df939cf7cea4200e3b0..2db4a14069c9ad06c336f62083a7e3e56b3d3de4 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -18,7 +18,7 @@ import { FormUtils } from '../../utils/formUtils'; import { Utils } from '../../utils/utils'; import { stepType } from '../step.type'; import { accountFormStep } from './account-form/accountFormStep.enum'; -import { formType } from './formType.enum'; +import { formType, formTypeParam } from './formType.enum'; import { personalOfferFormStep } from './personal-offer-form/personalOfferFormStep.enum'; import { profileFormStep } from './profile-form/profileFormStep.enum'; import { structureFormStep } from './structure-form/structureFormStep.enum'; @@ -31,6 +31,7 @@ import { structureFormStep } from './structure-form/structureFormStep.enum'; export class FormViewComponent implements OnInit, AfterViewInit { public routeParam: string; public formType = formType; + public formTypeParam = formTypeParam; public currentPage: stepType; public currentFormType: formType; public currentForm: UntypedFormGroup; @@ -135,14 +136,14 @@ export class FormViewComponent implements OnInit, AfterViewInit { const structureFormSteps = Object.keys(structureFormStep).length / 2 - 1; const personalOfferFormSteps = Object.keys(personalOfferFormStep).length / 2 - 1; const totalFormSteps = profileFormSteps + structureFormSteps + personalOfferFormSteps; - if (formType[this.routeParam] === formType.account) { + if (this.routeParam === formTypeParam.account) { this.nbSteps = 3; this.currentPage = accountFormStep.accountInfo; this.currentFormType = formType.account; this.createAccountForm(); this.currentForm = this.accountForm; } - if (formType[this.routeParam] === formType.register) { + if (this.routeParam === formTypeParam.register) { this.nbSteps = 3; this.currentPage = accountFormStep.accountInfo; this.currentFormType = formType.account; @@ -155,14 +156,14 @@ export class FormViewComponent implements OnInit, AfterViewInit { } }); } - if (formType[this.routeParam] === formType.profile) { + if (this.routeParam === formTypeParam.profile) { this.nbSteps = totalFormSteps; this.currentPage = profileFormStep.profileBeginningInfo; this.currentFormType = formType.profile; this.createProfileForm(); this.currentForm = this.profileForm; } - if (formType[this.routeParam] === formType.structure) { + if (this.routeParam === formTypeParam.structure) { if (!this.isEditMode) { this.nbSteps = structureFormSteps; this.currentPage = structureFormStep.structureChoice; @@ -178,7 +179,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { } } } - if (formType[this.routeParam] === formType.personaloffer) { + if (this.routeParam === formTypeParam.personaloffer) { this.nbSteps = personalOfferFormSteps; this.currentPage = personalOfferFormStep.personalOfferAccompaniment; this.currentFormType = formType.personaloffer; @@ -299,7 +300,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { const user = await this.profileService.getProfile(); if (user.job?.hasPersonalOffer) { this.previousSteps = 0; - this.router.navigateByUrl('form/personaloffer'); + this.router.navigateByUrl('formulaire/offre-personnelle'); } else { this.router.navigateByUrl('/'); } @@ -317,7 +318,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { this.saveStructureForm(); } if (type.formStep === structureFormStep.noStructure) { - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } break; case formType.personaloffer: @@ -355,13 +356,13 @@ export class FormViewComponent implements OnInit, AfterViewInit { this.structureService.getStructure(this.profile.structuresLink[0]).subscribe((structure) => { this.structure = new Structure(structure); this.previousSteps = 0; - this.router.navigateByUrl('form/personaloffer'); + this.router.navigateByUrl('formulaire/offre-personnelle'); }); } else { - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } } else { - this.router.navigateByUrl('form/structure'); + this.router.navigateByUrl('formulaire/structure'); } }); } @@ -369,7 +370,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { public savePersonalOfferForm(): void { this.personalOfferService.createPersonalOffer(this.structure._id, this.personalOfferForm.value).subscribe(() => { if (this.hasOtherPersonalOffer) { - this.router.navigateByUrl('form/structure'); + this.router.navigateByUrl('formulaire/structure'); } else { this.nextPage(); } @@ -386,9 +387,9 @@ export class FormViewComponent implements OnInit, AfterViewInit { if (user.job?.hasPersonalOffer) { this.structure = struct; this.previousSteps = 0; - this.router.navigateByUrl('form/personaloffer'); + this.router.navigateByUrl('formulaire/offre-personnelle'); } else { - this.router.navigateByUrl(`acteurs?id=${struct._id}`); + this.router.navigateByUrl(`acteurs?structure=${struct.permalink}`); } }); } diff --git a/src/app/form/form-view/formType.enum.ts b/src/app/form/form-view/formType.enum.ts index 41d8aa290b4579aad40ae8c1d2242d3fa48b1297..01dee2beb1f9e0211d3c8923ce0099793ddcd210 100644 --- a/src/app/form/form-view/formType.enum.ts +++ b/src/app/form/form-view/formType.enum.ts @@ -6,3 +6,12 @@ export enum formType { register, orientation, } + +export enum formTypeParam { + structure = 'structure', + profile = 'profil', + personaloffer = 'offre-personnelle', + account = 'compte', + register = 'inscription', + orientation = 'orientation', +} diff --git a/src/app/form/form-view/guards/personalOffer.guard.ts b/src/app/form/form-view/guards/personalOffer.guard.ts index 0652dbdcf38232dd4466a05fd979ec7dd7264c7c..239a15de836ab171ec9a2bcb908b74bdbad39f4b 100644 --- a/src/app/form/form-view/guards/personalOffer.guard.ts +++ b/src/app/form/form-view/guards/personalOffer.guard.ts @@ -1,5 +1,5 @@ -import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router'; import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router'; /** * Guard to assert that we are coming from the structure form. Otherwise redirect to home */ @@ -9,10 +9,10 @@ export class PersonalOfferGuard { canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean { if ( - route.routeConfig.path === 'personaloffer' && - (this.router.routerState.snapshot.url === '/profile' || - this.router.routerState.snapshot.url === '/form/profile' || - this.router.routerState.snapshot.url === '/form/structure' || + route.routeConfig.path === 'offre-personnelle' && + (this.router.routerState.snapshot.url === '/profil' || + this.router.routerState.snapshot.url === '/formulaire/profil' || + this.router.routerState.snapshot.url === '/formulaire/structure' || this.router.routerState.snapshot.url.includes('/join-request/')) ) { return true; diff --git a/src/app/form/form-view/personal-offer-form/personal-offer-form.component.ts b/src/app/form/form-view/personal-offer-form/personal-offer-form.component.ts index 1db582e46fddfe9c980f81e4cadbf5e75eb56add..d1a829e3afa56d2fac16249c022807fd9ab66296 100644 --- a/src/app/form/form-view/personal-offer-form/personal-offer-form.component.ts +++ b/src/app/form/form-view/personal-offer-form/personal-offer-form.component.ts @@ -77,6 +77,6 @@ export class PersonalOfferFormComponent implements OnChanges, OnInit { } public goToProfile(): void { - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } } diff --git a/src/app/form/orientation-form-view/orientation-form-view.component.ts b/src/app/form/orientation-form-view/orientation-form-view.component.ts index aab181800c1c2bb159fa9837839dff5164c79465..991c0b6dcf775fd7fd8652fddf7fbe26189ec8d9 100644 --- a/src/app/form/orientation-form-view/orientation-form-view.component.ts +++ b/src/app/form/orientation-form-view/orientation-form-view.component.ts @@ -756,6 +756,6 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked } } public goLogin(): void { - this.router.navigate(['/login'], { queryParams: { returnUrl: '/orientation' } }); + this.router.navigate(['/connexion'], { queryParams: { returnUrl: '/orientation' } }); } } diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 59f8b6b48e6ac282f90ff6b18b5042c93105f191..351fae1e54ebf02697d1ed4d5cd821f9a6906caf 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -1,5 +1,5 @@ -import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; import { AuthService } from '../services/auth.service'; /** * Guard to assert that we are logged in. Otherwise redirect to home @@ -15,7 +15,7 @@ export class AuthGuard { if (this.authService.isLoggedIn()) { return true; } - this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } }); + this.router.navigate(['/connexion'], { queryParams: { returnUrl: state.url } }); return false; } } diff --git a/src/app/guards/resetPasswordToken.guard.ts b/src/app/guards/resetPasswordToken.guard.ts index 77f212b1b385d0c23473429815efb47274c77d0e..49f20272f07b96970defc7f9863f1fe2d30c4eaf 100644 --- a/src/app/guards/resetPasswordToken.guard.ts +++ b/src/app/guards/resetPasswordToken.guard.ts @@ -18,7 +18,7 @@ export class ResetPasswordTokenGuard { if (token) { const validToken = await firstValueFrom(this.authService.checkResetPasswordToken(token)); if (!validToken) { - this.router.navigate(['/login']); + this.router.navigate(['/connexion']); return false; } } diff --git a/src/app/guards/role.guard.ts b/src/app/guards/role.guard.ts index 2162565376f8fedd99e2d5b1590c0d19ac60ab00..36631ab12dc9b13b98314a1a361559c9545c92a4 100644 --- a/src/app/guards/role.guard.ts +++ b/src/app/guards/role.guard.ts @@ -1,7 +1,9 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router'; +import { lastValueFrom } from 'rxjs'; import { ProfileService } from '../profile/services/profile.service'; import { AuthService } from '../services/auth.service'; +import { StructureService } from '../services/structure.service'; import { RouteRole } from '../shared/enum/routeRole.enum'; /** * Guard to assert that a user is authorized to access route. @@ -13,6 +15,7 @@ export class RoleGuard { private router: Router, private profileService: ProfileService, private authService: AuthService, + private structureService: StructureService, ) {} async canActivate(route: ActivatedRouteSnapshot): Promise<UrlTree | boolean> { @@ -21,8 +24,9 @@ export class RoleGuard { if (this.authService.isLoggedIn()) { if (this.profileService.isAdmin()) return true; if (allowedRoles.includes(RouteRole.structureAdmin)) { - const structureId = route.params.id; - if (await this.profileService.isLinkedToStructure(structureId)) { + const structurePermalink = route.params.permalink; + const structure = await lastValueFrom(this.structureService.getStructureByPermalink(structurePermalink)); + if (await this.profileService.isLinkedToStructure(structure._id)) { return true; } } diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index 028020ab1b348fc599744ad9d3b6ae3c8364af55..256280bcce90ca15d199c0e7000f38c8a8229609 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -39,12 +39,12 @@ <div class="rightHeader"> <div class="menuItems" role="menu"> <a - routerLink="/news" + routerLink="/actualites" role="menuitem" title="Actualités" [routerLinkActive]="'active'" i18n - [attr.aria-current]="isActive('/news')" + [attr.aria-current]="isActive('/actualites')" > Actualités </a> @@ -124,10 +124,10 @@ </div> <div class="links"> <a - routerLink="/news" + routerLink="/actualites" role="menuitem" [routerLinkActive]="'active'" - [attr.aria-current]="isActive('/news')" + [attr.aria-current]="isActive('/actualites')" (click)="closeMenu()" i18n >Actualités</a @@ -178,11 +178,11 @@ >Administration</a > <a - routerLink="/legal-notice" + routerLink="/mentions-legales" role="menuitem" i18n [routerLinkActive]="'active'" - [attr.aria-current]="isActive('/legal-notice')" + [attr.aria-current]="isActive('/mentions-legales')" (click)="closeMenu()" >Mentions légales</a > diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 2c3ae29c336cf178cc55f827cdc2864707536042..44e3e333d331dcdcc1a6d64595bd6c59d831d83f 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -59,7 +59,7 @@ export class HeaderComponent { } public goToProfile(): void { this.showProfileMenu = false; - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } public openMenu(): void { @@ -96,7 +96,7 @@ export class HeaderComponent { return false; } public goToLoginPage(): void { - this.router.navigateByUrl('login'); + this.router.navigateByUrl('connexion'); } public get isAdmin(): boolean { return this.profileService.isAdmin(); diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index dc9450ed958cb2f84782ce082f6677760b026762..5f4844aecb3ea9fd620b5e3b45e5d5eb3eb70ed4 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -71,7 +71,7 @@ export class LoginComponent implements OnInit { } public switchToResetPassword(): void { - this.router.navigate(['/reset-password']); + this.router.navigate(['/mot-de-passe-oublie']); } public async onSubmit(): Promise<void> { @@ -88,12 +88,12 @@ export class LoginComponent implements OnInit { await lastValueFrom(this.authService.login(this.f.email.value, this.f.password.value)); if (this.isWelcome) { - this.router.navigateByUrl('form/profile'); + this.router.navigateByUrl('formulaire/profil'); } else { if (this.returnUrl) { this.router.navigateByUrl(this.returnUrl); } else { - this.router.navigateByUrl('news'); + this.router.navigateByUrl('actualites'); } } } catch (e) { @@ -107,7 +107,7 @@ export class LoginComponent implements OnInit { } public goToAccountCreation(): void { - this.router.navigateByUrl('form/account'); + this.router.navigateByUrl('formulaire/compte'); } public getLoginStatusText(): string { diff --git a/src/app/models/owner.model.ts b/src/app/models/owner.model.ts index 89c4226c11f77f48a3603a30be24301660dbaad5..3152b228d274e069b0fe04a3288a20d89e2c0779 100644 --- a/src/app/models/owner.model.ts +++ b/src/app/models/owner.model.ts @@ -5,6 +5,7 @@ import { PersonalOffer } from './personalOffer.model'; export class Owner { email: string; _id: string; + permalink: string; name: string; surname: string; job?: Job; diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index bd9df1f41e1b1d004d34bd99d12b1c4acead4407..c25ad38b359fb717d381e9c6c69de3d3e4ce1df3 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -57,6 +57,7 @@ export class Structure { public alreadySelected? = false; public hasNoUserDN?: boolean = null; public hasUserWithAppointmentDN?: boolean = null; + public permalink = ''; constructor(obj?: any) { Object.assign(this, obj, { diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index f8aaddc789c2e1e5f8ca2c93bc232917a6944848..26577e5f6147cd8f665f5576be261176c42eb95a 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -6,6 +6,7 @@ import { PersonalOffer } from './personalOffer.model'; export class User { _id: string; id: string; + permalink: string; createdAt: Date; email: string; name: string; @@ -31,6 +32,7 @@ export class User { } export class UserAnnuary { _id: string; + permalink: string; name: string; surname: string; job: Job; diff --git a/src/app/newsletter-subscription/newsletter-subscription.component.html b/src/app/newsletter-subscription/newsletter-subscription.component.html index ca7ff6703f9cfb71412c144ded66894d7475357c..a613191838df9501b26b9c12a9a465ca3abefff3 100644 --- a/src/app/newsletter-subscription/newsletter-subscription.component.html +++ b/src/app/newsletter-subscription/newsletter-subscription.component.html @@ -28,7 +28,7 @@ <div class="link"> <a *ngIf="!subscriptionMod" routerLink="/newsletter">Inscription</a> - <a *ngIf="subscriptionMod" routerLink="/newsletter-unsubscribe">Désabonnement</a> + <a *ngIf="subscriptionMod" routerLink="/desabonnement-newsletter">Désabonnement</a> </div> </div> </form> diff --git a/src/app/post/components/post-card/post-card.component.ts b/src/app/post/components/post-card/post-card.component.ts index 52cf5b0452043dfe9661f321497beda0abcc070b..1844d30fd92ee217eeef9b87b9c94ae14bc00b7e 100644 --- a/src/app/post/components/post-card/post-card.component.ts +++ b/src/app/post/components/post-card/post-card.component.ts @@ -15,7 +15,7 @@ export class PostCardComponent { constructor(private router: Router) {} public showDetails(post: Post): void { - this.router.navigateByUrl('news/details/' + post.id, { state: { data: post } }); + this.router.navigateByUrl('actualites/details/' + post.slug, { state: { data: post } }); } public isAppelAProjet(): boolean { diff --git a/src/app/post/components/post-details/post-details.component.ts b/src/app/post/components/post-details/post-details.component.ts index 0131c534fda0feb228fef23ec05f7a861979d4d1..f429423bca4b4e84662dd541c186d17b24b84d75 100644 --- a/src/app/post/components/post-details/post-details.component.ts +++ b/src/app/post/components/post-details/post-details.component.ts @@ -29,8 +29,8 @@ export class PostDetailsComponent implements OnInit { this.post = new Post(history.state.data); this.post.safeHtml = this.sanitizer.bypassSecurityTrustHtml(this.post.html); } else { - const postId = this.activatedRoute.snapshot.paramMap.get('id'); - this.postService.getPost(postId).subscribe((post) => { + const postSlug = this.activatedRoute.snapshot.paramMap.get('slug'); + this.postService.getPost(postSlug).subscribe((post) => { this.post = post.posts[0]; this.post.safeHtml = this.sanitizer.bypassSecurityTrustHtml(this.post.html); }); diff --git a/src/app/post/components/post-header/post-header.component.ts b/src/app/post/components/post-header/post-header.component.ts index 953fc9aace5340fec98d6844349a6a5386619d7d..fd5c0a482da7101a0c0ce0143253ca8e09e33487 100644 --- a/src/app/post/components/post-header/post-header.component.ts +++ b/src/app/post/components/post-header/post-header.component.ts @@ -73,7 +73,7 @@ export class PostHeaderComponent implements OnInit { } private setQueryParam(): void { - this.router.navigate(['/news'], { + this.router.navigate(['/actualites'], { relativeTo: this.route, queryParams: { mainTag: this.getMainTag(), diff --git a/src/app/post/models/post.model.ts b/src/app/post/models/post.model.ts index 9ba0fe3e61adef05b42b2f2b1b71af1f6237d441..00ba5988e8b6d5c89c5a619e4969317fdfc006c5 100644 --- a/src/app/post/models/post.model.ts +++ b/src/app/post/models/post.model.ts @@ -14,6 +14,7 @@ export class Post { author: string; tags: Tag[]; safeHtml: SafeHtml; + slug: string; constructor(obj?: any) { Object.assign(this, obj); diff --git a/src/app/post/post-routing.module.ts b/src/app/post/post-routing.module.ts index c95c0ba7cbea2c96e03ae08ecea77819b367b348..a0c9993768b86bb6b6c6a7db44465f2ec1078e20 100644 --- a/src/app/post/post-routing.module.ts +++ b/src/app/post/post-routing.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; +import { RouterModule, Routes } from '@angular/router'; import { PostDetailsComponent } from './components/post-details/post-details.component'; import { PostListComponent } from './components/post-list/post-list.component'; import { NewsComponent } from './news.component'; @@ -18,7 +18,7 @@ const routes: Routes = [ component: PostListComponent, }, { - path: 'details/:id', + path: 'details/:slug', component: PostDetailsComponent, }, ], diff --git a/src/app/post/services/post.service.ts b/src/app/post/services/post.service.ts index 3e1d886d8a7600b789ebb8fcee8b5af962398748..d35d23885b05e9fdced36964a9d76af1ec69e93d 100644 --- a/src/app/post/services/post.service.ts +++ b/src/app/post/services/post.service.ts @@ -13,8 +13,8 @@ export class PostService { private readonly baseUrl = 'api/posts'; constructor(private http: HttpClient) {} - public getPost(idPost: string): Observable<PostWithMeta> { - return this.http.get<PostWithMeta>(`${this.baseUrl}/` + idPost).pipe( + public getPost(postSlug: string): Observable<PostWithMeta> { + return this.http.get<PostWithMeta>(`${this.baseUrl}/${postSlug}`).pipe( map((item: PostWithMeta) => { item.posts.forEach((post) => this.addAuthorToPost(post)); return new PostWithMeta(item); diff --git a/src/app/profile/edit/edit.component.ts b/src/app/profile/edit/edit.component.ts index a41ff417a81e1f777726b134a7a27e5e0e49a15e..0ab8834a267aaa5dea92b22ece7b5e55b429a5c5 100644 --- a/src/app/profile/edit/edit.component.ts +++ b/src/app/profile/edit/edit.component.ts @@ -281,7 +281,7 @@ export class EditComponent implements OnInit { localStorage.setItem('user', JSON.stringify(updatedUser)); this.authService.userSubject.next(updatedUser); this.updateInitialProfile(); - this.router.navigate(['/profile']); + this.router.navigate(['/profil']); }); } @@ -299,7 +299,7 @@ export class EditComponent implements OnInit { .updateProfile(this.selectedEmployer.name, this.selectedJob.name, this.selectedRdvChoice) .subscribe({ next: () => { - this.router.navigate(['/profile']); + this.router.navigate(['/profil']); this.notificationService.showSuccess('Vos informations ont bien été enregistrées'); }, error: () => { @@ -316,7 +316,7 @@ export class EditComponent implements OnInit { this.profileService.updateDescription(this.userProfile.description).subscribe(() => { this.notificationService.showSuccess('Vos informations ont bien été enregistrées'); this.updateInitialProfile(); - this.router.navigate(['/profile']); + this.router.navigate(['/profil']); }); } diff --git a/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts b/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts index 99e37853a1e32c53850066674ef48fc08e4e8865..28461141e83a2bc40d2dd58ae3b6591815b6605c 100644 --- a/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts +++ b/src/app/profile/personal-offer-edition/personal-offer-edition.component.ts @@ -107,7 +107,7 @@ export class PersonalOfferEditionComponent implements OnInit { this.initialPersonalOffer = this.personalOfferForm.value; this.personalOfferForm.markAsPristine(); }); - this.router.navigateByUrl('/profile'); + this.router.navigateByUrl('/profil'); } } @@ -137,7 +137,7 @@ export class PersonalOfferEditionComponent implements OnInit { this.notificationService.showError(`${err.error.message}`, 'Une erreur est survenue'); }, ); - this.router.navigate(['/profile']); + this.router.navigate(['/profil']); } public goBack(): void { diff --git a/src/app/profile/profile-routing.module.ts b/src/app/profile/profile-routing.module.ts index ecd292897d495d247e816a8826e9f0a09bcd120e..9f3dbb5ec4e1843e61ecc5084ca6055120a29133 100644 --- a/src/app/profile/profile-routing.module.ts +++ b/src/app/profile/profile-routing.module.ts @@ -23,13 +23,13 @@ const footerOutletRoute: Route = { const routes: Routes = [ { - path: 'edit', + path: 'edition', canActivate: [AuthGuard], canDeactivate: [DeactivateGuard], component: EditComponent, }, { - path: 'structures-management', + path: 'gestion-structures', component: StructuresManagementComponent, }, footerOutletRoute, @@ -41,13 +41,13 @@ const routes: Routes = [ component: ProfileComponent, }, { - path: ':id', + path: ':userPermalink', component: ProfileComponent, }, ], }, { - path: 'edit-structure/:id', + path: 'edition-structure/:permalink', component: StructureEditionSummaryComponent, canActivate: [RoleGuard], data: { allowedRoles: [RouteRole.structureAdmin] }, @@ -56,7 +56,7 @@ const routes: Routes = [ }, }, { - path: 'edit-personal-offer/:id', + path: 'edition-offre-personnelle/:id', component: PersonalOfferEditionComponent, canActivate: [IsPersonalOfferOwnerGuard], resolve: { @@ -64,7 +64,7 @@ const routes: Routes = [ }, }, { - path: 'structure-members-management/:id', + path: 'gestion-membres/:permalink', component: StructureMembersManagementComponent, canActivate: [RoleGuard], data: { allowedRoles: [RouteRole.structureAdmin] }, diff --git a/src/app/profile/profile-structure/personal-offer/personal-offer.component.ts b/src/app/profile/profile-structure/personal-offer/personal-offer.component.ts index 526d64fc4c253615e50a32b770a1d0a33721137b..1fde1ca4cbe750471c698271ce72462dafd7eba8 100644 --- a/src/app/profile/profile-structure/personal-offer/personal-offer.component.ts +++ b/src/app/profile/profile-structure/personal-offer/personal-offer.component.ts @@ -15,7 +15,7 @@ export class PersonalOfferComponent { constructor(private router: Router) {} public goToEditPersonalOffer(): void { - this.router.navigateByUrl(`/profile/edit-personal-offer/${this.personalOffer._id}`, { + this.router.navigateByUrl(`/profil/edition-offre-personnelle/${this.personalOffer._id}`, { state: { structureName: this.structureName }, }); } diff --git a/src/app/profile/profile-structure/profile-structure.component.ts b/src/app/profile/profile-structure/profile-structure.component.ts index cf36739743df94a66b9d38dfa07f8082253f4118..6648500aad3e016d0e11fd59ac4f37a6b86bc432 100644 --- a/src/app/profile/profile-structure/profile-structure.component.ts +++ b/src/app/profile/profile-structure/profile-structure.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Router } from '@angular/router'; import { DateTime } from 'luxon'; import { Structure } from '../../models/structure.model'; import { StructureWithOwners } from '../../models/structureWithOwners.model'; @@ -23,7 +23,7 @@ export class ProfileStructureComponent implements OnInit { @Input() public isPublic: boolean; @Input() public isPending = false; @Input() public joinRequestDate: string | null; - @Output() cancelJoin = new EventEmitter<any>(); + @Output() cancelJoin = new EventEmitter<string>(); public membersWithJobWithPO: User[] = []; public structureForm: FormGroup; @@ -33,7 +33,6 @@ export class ProfileStructureComponent implements OnInit { public personalOffer: PersonalOffer; constructor( - private route: ActivatedRoute, private router: Router, private userService: UserService, private searchService: SearchService, @@ -82,16 +81,16 @@ export class ProfileStructureComponent implements OnInit { this.router.navigateByUrl('/home'); } public goToDetail(): void { - this.router.navigate(['/profile'], { queryParams: { id: this.structure._id } }); + this.router.navigate([], { queryParams: { structure: this.structure.permalink } }); } public goToOffer(): void { - this.router.navigate(['/form/personaloffer'], { state: { structure: this.structure } }); + this.router.navigate(['/formulaire/offre-personnelle'], { state: { structure: this.structure } }); } public goToEditStructure(): void { - this.router.navigateByUrl(`/profile/edit-structure/${this.structure._id}`); + this.router.navigateByUrl(`/profil/edition-structure/${this.structure.permalink}`); } public goToStructureMembersManagement(): void { - this.router.navigateByUrl(`/profile/structure-members-management/${this.structure._id}`); + this.router.navigateByUrl(`/profil/gestion-membres/${this.structure.permalink}`); } public isValid(): boolean { return this.structureForm.valid; diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 86f1a4969126257815f048e2b5051b67bfd73b3a..7e899f0c544858e4cdc156fffe572e49e6959976 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -35,11 +35,11 @@ export class ProfileComponent implements OnInit { ngOnInit(): void { this.route.params.subscribe((urlParams) => { - const userId = urlParams.id ? urlParams.id : ''; - if (userId) { + const userPermalink = urlParams.userPermalink || ''; + if (userPermalink) { this.isPublic = true; this.userService - .getUser(userId) + .getUserByPermalink(userPermalink) .pipe( map((res) => res), catchError(() => { @@ -106,20 +106,16 @@ export class ProfileComponent implements OnInit { } public goToProfileEdit(tabToSelect?: string): void { if (tabToSelect) { - this.router.navigateByUrl('/profile/edit', { state: { data: tabToSelect } }); + this.router.navigateByUrl('/profil/edition', { state: { data: tabToSelect } }); } else { - this.router.navigateByUrl('/profile/edit'); + this.router.navigateByUrl('/profil/edition'); } } public goToStructuresManagement(): void { - this.router.navigateByUrl('/profile/structures-management'); + this.router.navigateByUrl('/profil/gestion-structures'); } public goToFormStructure(): void { - this.router.navigateByUrl('/form/structure'); - } - - public addStructure(): void { - this.router.navigateByUrl('/form/structure'); + this.router.navigateByUrl('/formulaire/structure'); } public cancelJoin(idStructure: string): void { this.userService.cancelJoin(idStructure, this.userProfile._id).subscribe({ diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts index 9a9b89aaf63d434934b95e209ea133a406250862..c775ab218b4f3f949977fcb3fd1f9304afb22b6f 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -94,7 +94,7 @@ export class StructureEditionSummaryComponent implements OnInit { } public goToEdit(step: structureFormStep): void { - this.router.navigate(['/form/structure', this.structure._id, structureFormStep[step]]); + this.router.navigate(['/formulaire/structure', this.structure.permalink, structureFormStep[step]]); } public isFormValid(): boolean { @@ -181,6 +181,6 @@ export class StructureEditionSummaryComponent implements OnInit { } public goToManageMembers(): void { - this.router.navigate([`/profile/structure-members-management/${this.structure._id}`]); + this.router.navigate([`/profil/gestion-membres/${this.structure.permalink}`]); } } diff --git a/src/app/profile/structures-management/structures-management.component.ts b/src/app/profile/structures-management/structures-management.component.ts index 193e936fa6f660bfba84035157617acee7150229..7be96b72b8eb42eaa22b23467911407e502732a3 100644 --- a/src/app/profile/structures-management/structures-management.component.ts +++ b/src/app/profile/structures-management/structures-management.component.ts @@ -38,12 +38,12 @@ export class StructuresManagementComponent implements OnInit { history.back(); } public goToFormStructure(): void { - this.router.navigateByUrl('/form/structure'); + this.router.navigateByUrl('/formulaire/structure'); } private shouldRedirect(structures: StructureWithOwners[] | Observable<any>[]): void { if (!structures.length) { - this.router.navigate(['/profile']); + this.router.navigate(['/profil']); } } diff --git a/src/app/reset-password/forgot-password.component.ts b/src/app/reset-password/forgot-password.component.ts index 81fd6e5d9123eec050411a33eba3f4f0c810cfeb..8f3e89dc93e33e671f0960bbaa6f38ee2f923d45 100644 --- a/src/app/reset-password/forgot-password.component.ts +++ b/src/app/reset-password/forgot-password.component.ts @@ -54,6 +54,6 @@ export class ForgotPasswordComponent implements OnInit { } public goLogin(): void { - this.router.navigateByUrl('/login'); + this.router.navigateByUrl('/connexion'); } } diff --git a/src/app/resolvers/structure.resolver.ts b/src/app/resolvers/structure.resolver.ts index 14fdc214f611f09d9c9d755341f4ffb458776ae3..fab997a45f270d2314e130d4fdb1889da2aeb507 100644 --- a/src/app/resolvers/structure.resolver.ts +++ b/src/app/resolvers/structure.resolver.ts @@ -20,11 +20,11 @@ export class StructureResolver { ) {} resolve(route: ActivatedRouteSnapshot): Observable<Structure> { - const structureId = route.params.id; + const structurePermalink = route.params.permalink || route.queryParams.structure; - if (structureId) { + if (structurePermalink) { forkJoin({ - structure: this.structureService.getStructure(structureId).pipe( + structure: this.structureService.getStructureByPermalink(structurePermalink).pipe( map((res) => res), catchError(() => { this.router.navigate(['/home']); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index d303885a1f18ff1c137c0cb4d8a613cac62acc46..6e4382da4a0d22a1dcd03e8415be4fe09303329d 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -36,7 +36,7 @@ export class AuthService { public logout(): void { localStorage.removeItem('user'); this.userSubject.next(null); - window.location.replace('/home'); + window.location.replace('/actualites'); } public isLoggedIn(): boolean { diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 8671c4251bc7ea0742bcf34cd9365c1ff593fac4..848b1e654532a3c3ab2d215a4ab635bc032f1026 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -40,6 +40,10 @@ export class StructureService { return this.http.get<Structure>(`${this.baseUrl}/${id}`); } + public getStructureByPermalink(permalink: string): Observable<Structure> { + return this.http.get<Structure>(`${this.baseUrl}/permalink/${permalink}`); + } + public delete(id: string): Observable<Structure> { return this.http.delete<Structure>(`${this.baseUrl}/${id}`); } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index 1bcb892b6c397f8ab1eddf6531937d6fc8733154..795bd3d318402bca04c9367cfbcd10afb0d5b854 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -14,12 +14,15 @@ export class UserService { public getUser(userId: string): Observable<User> { return this.http.get<User>(`${this.baseUrl}/${userId}`); } + public getUserByPermalink(permalink: string): Observable<User> { + return this.http.get<User>(`${this.baseUrl}/permalink/${permalink}`); + } public joinStructure(id: string, email: string): Observable<Structure> { return this.http.post<any>(`${this.baseUrl}/join-request/${id}`, { email }); } public validateJoinStructure(token: string, status: string): Observable<any> { - return this.http.get<any>(`${this.baseUrl}/join-validate/${token}/${status}`); + return this.http.get<Structure>(`${this.baseUrl}/join-validate/${token}/${status}`); } public cancelJoin(idStructure: string, idUser: string): Observable<any> { return this.http.get<any>(`${this.baseUrl}/join-cancel/${idStructure}/${idUser} diff --git a/src/app/shared/components/member-card/member-card.component.ts b/src/app/shared/components/member-card/member-card.component.ts index 07a0849ab91d6475ab4d11dbb144873eabd1ec31..bbc3c7c022a6a56f8f957f2a489bba92c566140d 100644 --- a/src/app/shared/components/member-card/member-card.component.ts +++ b/src/app/shared/components/member-card/member-card.component.ts @@ -67,7 +67,7 @@ export class MemberCardComponent implements OnInit { cardClicked(): void { if (this.redirectToProfile) { this.windowScrollService.scrollYToPreserve.next(this.windowScrollService.scrollY.value); - this.router.navigateByUrl(`/profile/${this.member._id}`); + this.router.navigateByUrl(`/profil/${this.member.permalink}`); } else if (this.showRadioButton) { this.selectedCard.emit(this.member._id); } diff --git a/src/app/structure-list/components/card/card.component.ts b/src/app/structure-list/components/card/card.component.ts index c1571a72d4a03f4cc9e0e956b2f6c5c35378d485..22d42859b273406e26ec485aba0353ef234e4be0 100644 --- a/src/app/structure-list/components/card/card.component.ts +++ b/src/app/structure-list/components/card/card.component.ts @@ -65,13 +65,12 @@ export class CardComponent implements OnInit { public cardClicked(): void { if (this.redirectToStructure) { this.showDetails.emit(this.structure); - const queryString = this.route.snapshot.queryParamMap.get('search'); this.router.navigate([], { relativeTo: this.route, queryParams: { - id: this.structure._id, - ...(queryString && { search: queryString }), + structure: this.structure.permalink, }, + queryParamsHandling: 'merge', state: { isOrientation: this.isOrientation }, }); } else { diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index d28eabfb8fe0e8121df892d6c95857b41cc7a761..c42966542d0c8db813333b16d310aa1fc5e0f056 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -73,23 +73,19 @@ export class StructureDetailsComponent implements OnInit { ) {} async ngOnInit(): Promise<void> { - this.route.queryParams.subscribe((queryParams) => { - if (queryParams.id) { - this.structureService.getStructure(queryParams.id).subscribe((structure) => { - this.structure = new Structure(structure); - this.profileIsLinkedToStructure(this.structure._id); - this.isLoading = true; - this.initForm(); - }); + this.route.data.subscribe((data) => { + if (data.structure) { + this.structure = new Structure(data.structure); + this.profileIsLinkedToStructure(this.structure._id); + this.isLoading = true; + this.initForm(); } else { this.structure = null; } - this.showButtons = !history.state.isOrientation; - }); - this.route.data.subscribe((data) => { if (data.fullScreen) { this.fullScreen = true; } + this.showButtons = !history.state.isOrientation; }); } @@ -138,7 +134,12 @@ export class StructureDetailsComponent implements OnInit { } public close(): void { - this.router.navigate([]); + this.router.navigate([], { + queryParams: { + structure: null, + }, + queryParamsHandling: 'merge', + }); } public print(): void { @@ -165,7 +166,9 @@ export class StructureDetailsComponent implements OnInit { public handleJoin(): void { if (!this.userIsLoggedIn()) { - this.router.navigate(['login'], { queryParams: { returnUrl: `acteurs?id=${this.structure._id}` } }); + this.router.navigate(['connexion'], { + queryParams: { returnUrl: `acteurs?structure=${this.structure.permalink}` }, + }); return; } @@ -179,7 +182,7 @@ export class StructureDetailsComponent implements OnInit { } public handleModify(): void { - this.router.navigate(['profile', 'edit-structure', this.structure._id]); + this.router.navigate(['profil', 'edition-structure', this.structure.permalink]); } public deleteStructure(shouldDelete: boolean): void { @@ -202,7 +205,9 @@ export class StructureDetailsComponent implements OnInit { this.structureService .claimStructureWithAccount(this.structure._id, this.authService.userValue.username) .subscribe(); - this.router.navigate(['join-request', this.structure._id], { state: { isClaimed: !this.structure.hasNoUserDN } }); + this.router.navigate(['join-request', this.structure.permalink], { + state: { isClaimed: !this.structure.hasNoUserDN }, + }); } } @@ -210,7 +215,9 @@ export class StructureDetailsComponent implements OnInit { this.toggleJoinModal(); if (shouldJoin) { this.usersService.joinStructure(this.structure._id, this.authService.userValue.username).subscribe(); - this.router.navigate(['join-request', this.structure._id], { state: { isClaimed: !this.structure.hasNoUserDN } }); + this.router.navigate(['join-request', this.structure.permalink], { + state: { isClaimed: !this.structure.hasNoUserDN }, + }); } } diff --git a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts index de56f479e21df8c3f385e010884fa7dfc6a8e030..0f136ba8e0f971d809b9484f1da5e30c1bd82830 100644 --- a/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts @@ -44,7 +44,6 @@ export class StructureListSearchComponent implements OnInit { constructor( public searchService: SearchService, private activatedRoute: ActivatedRoute, - private route: ActivatedRoute, private router: Router, private elementRef: ElementRef, ) {} @@ -98,7 +97,7 @@ export class StructureListSearchComponent implements OnInit { public updateUrlParams(filters: Filter[]): void { // No url update if the page is displaying structure details, because it must keep the url with the structure id, neither for orientation if ( - (this.activatedRoute.snapshot.queryParams.id && filters.length === 0) || + (this.activatedRoute.snapshot.queryParams.structure && filters.length === 0) || this.router.url.startsWith('/orientation') ) { return; @@ -116,7 +115,7 @@ export class StructureListSearchComponent implements OnInit { this.checkedModulesFilter = this.utils.convertFiltersToModule(filters); this.router.navigate(['./'], { - relativeTo: this.route, + relativeTo: this.activatedRoute, queryParams: queryString, }); } diff --git a/src/app/structure-list/services/search.service.ts b/src/app/structure-list/services/search.service.ts index f8e23213cc83335c8adbf38491a61dc6ea2952e2..c0a3fd49454795b1d61661ebb181b260756502c4 100644 --- a/src/app/structure-list/services/search.service.ts +++ b/src/app/structure-list/services/search.service.ts @@ -34,13 +34,14 @@ export class SearchService { jobsGroup?: string[], employers?: string[], ): Promise<SearchResults> { - return lastValueFrom( + const users = await lastValueFrom( this.http.post<SearchResults>(`/api/userRegistry/?search=${searchTerm}`, { jobsGroup, employer: employers, page, }), ); + return users; } public getUserRegistryCount(): Observable<number> { return this.http.get<any>(`/api/userRegistry/count`).pipe(); diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index 50f12a4aaa3632f69fda7c8aed57eef93b36f7ad..19745a4f3f2b13803300b10cb1a3276abfd71cf6 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router'; import { GeoJson } from '../map/models/geojson.model'; import { Structure } from '../models/structure.model'; import { AuthService } from '../services/auth.service'; -import { StructureService } from '../services/structure.service'; import { PrintService } from '../shared/service/print.service'; @Component({ @@ -30,17 +29,12 @@ export class StructureListComponent implements OnChanges, OnInit { constructor( private route: ActivatedRoute, private router: Router, - private structureService: StructureService, private authService: AuthService, private printService: PrintService, ) { - this.route.queryParams.subscribe((queryParams) => { - if (queryParams.id) { - if (!this.structure) { - this.structureService.getStructure(queryParams.id).subscribe((s) => { - this.showDetails(new Structure(s)); - }); - } + this.route.data.subscribe((data) => { + if (data.structure) { + this.showDetails(new Structure(data.structure)); } else { this.closeDetails(); } @@ -59,8 +53,9 @@ export class StructureListComponent implements OnChanges, OnInit { this.router.navigate([], { relativeTo: this.route, queryParams: { - id: this.selectedStructure._id, + structure: this.selectedStructure.permalink, }, + queryParamsHandling: 'merge', }); } if (changes.structureList) { @@ -91,9 +86,9 @@ export class StructureListComponent implements OnChanges, OnInit { public addStructure(): void { if (!this.authService.isLoggedIn()) { - this.router.navigateByUrl('/login'); + this.router.navigateByUrl('/connexion'); } else { - this.router.navigateByUrl('/form/structure'); + this.router.navigateByUrl('/formulaire/structure'); } } diff --git a/src/app/structure/structure-join/structure-join.component.html b/src/app/structure/structure-join/structure-join.component.html index 8258487400d9b9ed53c05e52f5b0212505400094..67f2d78942ae044ae4a068566ae49e9e36d688b4 100644 --- a/src/app/structure/structure-join/structure-join.component.html +++ b/src/app/structure/structure-join/structure-join.component.html @@ -20,35 +20,35 @@ <ng-container *ngIf="!structureName && !isLoading && validationToken"> <div class="container"> <div class="page"> - <img *ngIf="error" src="../../../assets/form/structureNeutral.svg" alt="join error" /> + <img *ngIf="errorStatus" src="../../../assets/form/structureNeutral.svg" alt="join error" /> <img - *ngIf="!error && isStructureJoinValidated === 'true'" + *ngIf="!errorStatus && isStructureJoinValidated === 'true'" src="../../../assets/form/structureCreated.svg" alt="join accepted" /> <img - *ngIf="!error && isStructureJoinValidated === 'false'" + *ngIf="!errorStatus && isStructureJoinValidated === 'false'" src="../../../assets/form/structureNegatif.svg" alt="join refused" /> - <h2 *ngIf="error && error === 404"> + <h2 *ngIf="errorStatus && errorStatus === 404"> {{ errorEnum.Other }} </h2> - <h2 *ngIf="error && error === 403"> + <h2 *ngIf="errorStatus && errorStatus === 403"> {{ errorEnum.Expired }} </h2> - <h2 *ngIf="error && error === 422"> + <h2 *ngIf="errorStatus && errorStatus === 422"> {{ errorEnum.AlreadyLinked }} </h2> - <h2 *ngIf="this.structureJoinedId && !error"> + <h2 *ngIf="this.structureJoined && !errorStatus"> L'utilisateur a été {{ isStructureJoinValidated === 'true' ? 'accepté' : 'refusé' }} dans la structure. </h2> - <div *ngIf="this.structureJoinedId && !error" class="subtitle"> + <div *ngIf="this.structureJoined && !errorStatus" class="subtitle"> Vous avez {{ isStructureJoinValidated === 'true' ? 'accepté' : 'refusé' }} la demande d'ajout dans la structure - {{ structureJoinedName }} + {{ structureJoined.structureName }} </div> - <div *ngIf="error && (error === 403 || error === 422)" class="subtitle"> + <div *ngIf="errorStatus && (errorStatus === 403 || errorStatus === 422)" class="subtitle"> Il semblerait que la demande d’adhésion ait déjà été traitée ou que le mail soit expiré. </div> </div> diff --git a/src/app/structure/structure-join/structure-join.component.ts b/src/app/structure/structure-join/structure-join.component.ts index d441729c390549d2dd154389568d1a1265a09647..5180bf1c83e3db6e2910f666441fddabf9b6d57f 100644 --- a/src/app/structure/structure-join/structure-join.component.ts +++ b/src/app/structure/structure-join/structure-join.component.ts @@ -20,9 +20,8 @@ export class StructureJoinComponent implements OnInit { public isStructureJoinValidated = null; public validationToken = null; public isLoading: boolean; - public structureJoinedId: string; - public structureJoinedName: string; - public error: any; + public structureJoined: Structure; + public errorStatus: number; public errorEnum = JoinErrors; constructor( @@ -52,11 +51,10 @@ export class StructureJoinComponent implements OnInit { if (this.isStructureJoinValidated !== null && this.validationToken) { this.usersService.validateJoinStructure(this.validationToken, this.isStructureJoinValidated).subscribe({ next: (res) => { - this.structureJoinedId = res.id; - this.structureJoinedName = res.name; + this.structureJoined = res; }, error: (err) => { - this.error = err.status; + this.errorStatus = err.status; console.error(err); this.isLoading = false; }, @@ -68,10 +66,10 @@ export class StructureJoinComponent implements OnInit { public handleFinish(): void { this.routerListener.goToPreviousUrl(); } - public handleCallback(): any { - if (this.structureJoinedId) { - return this.router.navigateByUrl(`/acteurs?id=${this.structureJoinedId}`); + public handleCallback(): void { + if (this.structureJoined) { + this.router.navigateByUrl(`/acteurs?structure=${this.structureJoined.permalink}`); } - return this.router.navigateByUrl(`/acteurs`); + this.router.navigateByUrl(`/acteurs`); } } diff --git a/src/sitemap.xml b/src/sitemap.xml index 2b2ff2cc9265168481d2445a8c3515a5d29279b8..42905c49decee212c5ced0ec391a8f561f37ea6c 100644 --- a/src/sitemap.xml +++ b/src/sitemap.xml @@ -1,34 +1,45 @@ <?xml version="1.0" encoding="UTF-8"?> -<urlset - xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 - http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> -<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com --> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + <url> + <loc>https://resin.grandlyon.com/</loc> + <priority>1.00</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> + <url> + <loc>https://resin.grandlyon.com/actualites</loc> + <priority>0.80</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> -<url> - <loc>https://resin.grandlyon.com/</loc> - <priority>1.00</priority> - <lastmod>2021-05-04T13:28:32+00:00</lastmod> -</url> + <url> + <loc>https://resin.grandlyon.com/acteurs</loc> + <priority>0.80</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> -<url> - <loc>https://resin.grandlyon.com/news</loc> - <priority>0.80</priority> - <lastmod>2021-05-04T13:28:32+00:00</lastmod> -</url> + <url> + <loc>https://resin.grandlyon.com/orientation</loc> + <priority>0.80</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> -<url> - <loc>https://resin.grandlyon.com/acteurs</loc> - <priority>0.80</priority> - <lastmod>2021-05-04T13:28:32+00:00</lastmod> -</url> + <url> + <loc>https://resin.grandlyon.com/newsletter</loc> + <priority>0.64</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> -<url> - <loc>https://resin.grandlyon.com/page/qui-sommes-nous</loc> - <priority>0.64</priority> - <lastmod>2022-01-04T15:28:32+00:00</lastmod> -</url> + <url> + <loc>https://resin.grandlyon.com/mentions-legales</loc> + <priority>0.64</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> -</urlset> + <url> + <loc>https://resin.grandlyon.com/page/qui-sommes-nous</loc> + <priority>0.64</priority> + <lastmod>2024-05-28T15:47:00+00:00</lastmod> + </url> + +</urlset> \ No newline at end of file