diff --git a/src/app/form/form-view/form-view.component.ts b/src/app/form/form-view/form-view.component.ts index b6fd2d625d8f3e34125ea3fbdfd6df2ebaa4eba5..7d8a68e68f6a6fa77cddc06be4e9d4de1438de2d 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 239a15de836ab171ec9a2bcb908b74bdbad39f4b..3b15dc3263dcdcd3d797704204f45b42713f468f 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 a8a261b1e026dad2da402f70c76a47d190bc16f3..57126e2d41171452a1328a1051a225a17893b788 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 815eafa41606833bb839e133f6ecf2a73db9a836..52d7fbe092bf4b172a187e397a7da9569897ee34 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 1fde1ca4cbe750471c698271ce72462dafd7eba8..9c6a10a7a1467c623569269fd52a702eda72e916 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 1a66bb1db15c950a3c616daf403cd1ca9b7890e3..c676a44304447326ffce398f8a2aafdd88d86feb 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]]);