From 308a49ef02f29a0765de47ba875fff6586f793fb Mon Sep 17 00:00:00 2001 From: Etienne Loupias <eloupias@grandlyon.com> Date: Wed, 11 Dec 2024 14:17:40 +0100 Subject: [PATCH] create or add personalOffer --- src/app/form/form-view/form-view.component.ts | 7 ++++++- .../form/form-view/guards/personalOffer.guard.ts | 3 ++- .../personal-offer-training-type.component.html | 1 + .../personal-offer-edition.component.ts | 5 +++++ .../personal-offer/personal-offer.component.ts | 9 --------- .../structure-edition-summary.component.ts | 14 +++++++++++--- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index b6fd2d625..7d8a68e68 100644 --- a/src/app/form/form-view/form-view.component.ts +++ b/src/app/form/form-view/form-view.component.ts @@ -181,7 +181,12 @@ export class FormViewComponent implements OnInit, AfterViewInit { } if (this.routeParam === formTypeParam.personaloffer) { this.nbSteps = personalOfferFormSteps; - this.currentPage = personalOfferFormStep.personalOfferAccompaniment; + if (this.isPersonalOfferProfile && history.state.page) { + // Convert string 'personalOfferTrainingType' to enum + this.currentPage = personalOfferFormStep[history.state.page as keyof typeof personalOfferFormStep]; + } else { + this.currentPage = personalOfferFormStep.personalOfferAccompaniment; + } this.currentFormType = formType.personaloffer; this.createPersonalOfferForm(new PersonalOffer()); this.currentForm = this.personalOfferForm; diff --git a/src/app/form/form-view/guards/personalOffer.guard.ts b/src/app/form/form-view/guards/personalOffer.guard.ts index 239a15de8..3b15dc326 100644 --- a/src/app/form/form-view/guards/personalOffer.guard.ts +++ b/src/app/form/form-view/guards/personalOffer.guard.ts @@ -13,7 +13,8 @@ export class PersonalOfferGuard { (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/')) + this.router.routerState.snapshot.url.includes('/join-request/') || + this.router.routerState.snapshot.url.includes('/edition-structure/')) ) { return true; } diff --git a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.html b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.html index a8a261b1e..57126e2d4 100644 --- a/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.html +++ b/src/app/form/form-view/personal-offer-form/personal-offer-training-type/personal-offer-training-type.component.html @@ -5,6 +5,7 @@ <p>Facultatif</p> </div> <app-training-type-picker + *ngIf="trainingCategories?.length > 0" [baseSkills]="personalOfferForm.get('categories').get('baseSkills').value" [advancedSkills]="personalOfferForm.get('categories').get('advancedSkills').value" [trainingCategories]="trainingCategories" 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 815eafa41..52d7fbe09 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 @@ -40,6 +40,7 @@ export class PersonalOfferEditionComponent implements OnInit { ) {} ngOnInit(): void { + // eslint-disable-next-line rxjs/no-async-subscribe this.route.data.subscribe(async (data: Data & { personalOffer: PersonalOffer }) => { if (data.personalOffer) { await this.setCategories(); @@ -49,6 +50,10 @@ export class PersonalOfferEditionComponent implements OnInit { } }); this.structureName = history.state.structureName; + if (history.state.tab) { + // Convert string 'digitalSkills' to enum + this.currentTab = tabsEnum[history.state.tab as keyof typeof tabsEnum]; + } } public getTabsNames(): string[] { 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 1fde1ca4c..9c6a10a7a 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 @@ -1,5 +1,4 @@ import { Component, Input } from '@angular/core'; -import { Router } from '@angular/router'; import { PersonalOffer } from './../../../models/personalOffer.model'; @Component({ @@ -11,12 +10,4 @@ export class PersonalOfferComponent { @Input() public personalOffer: PersonalOffer; @Input() public isPublic: boolean; @Input() public structureName?: string; - - constructor(private router: Router) {} - - public goToEditPersonalOffer(): void { - this.router.navigateByUrl(`/profil/edition-offre-personnelle/${this.personalOffer._id}`, { - state: { structureName: this.structureName }, - }); - } } 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 1a66bb1db..c676a4430 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 @@ -167,11 +167,19 @@ export class StructureEditionSummaryComponent implements OnInit { this.isGoToEdit = true; if (offer?.user) { if (offer.offers._id) { - this.router.navigateByUrl(`/profil/edition-offre-personnelle/${offer.offers._id}`, { - state: { structureName: this.structure.structureName }, + this.router.navigate([`/profil/edition-offre-personnelle/${offer.offers._id}`], { + state: { + structureName: this.structure.structureName, + tab: step === structureFormStep.structureTrainingType ? 'digitalSkills' : '', + }, }); } else { - this.router.navigate(['/formulaire/offre-personnelle'], { state: { structure: this.structure } }); + this.router.navigate(['/formulaire/offre-personnelle'], { + state: { + structure: this.structure, + page: step === structureFormStep.structureTrainingType ? 'personalOfferTrainingType' : '', + }, + }); } } else { this.router.navigate(['/formulaire/structure', this.structure.permalink, structureFormStep[step]]); -- GitLab