diff --git a/src/app/form/orientation-form-view/enums/orientation.enums.ts b/src/app/form/orientation-form-view/enums/orientation.enums.ts index 84c3b9ee735f96da242792bb6212e0e9006f6baf..ef4c4b7b12a03e695066d552ef8d7a3458379f31 100644 --- a/src/app/form/orientation-form-view/enums/orientation.enums.ts +++ b/src/app/form/orientation-form-view/enums/orientation.enums.ts @@ -1,12 +1,13 @@ export enum AppointmentSteps { infoScreen, - structureOrientator, pmrAccess, location, carto, makeAppointment, mediationBeneficiaryInfo, + structureOrientator, rdvEnd, + orientationRecap, } export enum FiltersSteps { @@ -23,7 +24,11 @@ export enum HotlineMediationSteps { mediationBeneficiaryInfo, mediationHoursSelection, mediationLanguageSelection, + comments, + structureOrientator, orientationRecap, + rdvEnd, + orientationPrint, } export enum OnlineDemarche { @@ -50,6 +55,7 @@ export enum PreferredLanguages { arabic = 'Arabe', } export enum RecapsType { + appointment, onlineMediation, structure, } @@ -58,8 +64,8 @@ export enum StructuresListSteps { pmrAccess, address, structureChoice, - structureOrientator, mediationBeneficiaryInfo, comments, + structureOrientator, orientationRecap, } diff --git a/src/app/form/orientation-form-view/global-components/orientation-recap/orientation-recap.component.ts b/src/app/form/orientation-form-view/global-components/orientation-recap/orientation-recap.component.ts index d6f6f83d22a1b67ee84c2d81a488fd005d5a71e6..de9cc90c3c0324f10809ed95257c008db608ce3c 100644 --- a/src/app/form/orientation-form-view/global-components/orientation-recap/orientation-recap.component.ts +++ b/src/app/form/orientation-form-view/global-components/orientation-recap/orientation-recap.component.ts @@ -1,8 +1,10 @@ import { DatePipe } from '@angular/common'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; +import { Owner } from '../../../../models/owner.model'; import { Structure } from '../../../../models/structure.model'; import { Module } from '../../../../structure-list/models/module.model'; +import { Utils } from '../../../../utils/utils'; import { RecapsType } from '../../enums/orientation.enums'; @Component({ @@ -13,20 +15,29 @@ import { RecapsType } from '../../enums/orientation.enums'; export class OrientationRecapComponent implements OnInit { @Input() form: UntypedFormGroup; @Input() recapType: RecapsType; + @Input() socialWorker?: Owner; + @Input() structureRDV?: Structure; @Output() checkValidation = new EventEmitter<any>(); + public utils = new Utils(); public needs: Module[]; public structuresToPrint: Structure[]; public orientator: { structureName: string; structureMail: string; structurePhone: string }; public comment: string; - public beneficiary: any; + public beneficiary: { name: string; surname: string }; public recap: { day: string; hours: string; month: string; language?: string }; constructor(private datePipe: DatePipe) {} ngOnInit(): void { this.checkValidation.emit(); - this.needs = this.form.get('filters').value; + // When requesting for an appointments, we save Filters within the form 'onlineDemarcheType', + // instead of Modules within the form 'filters'. This harmonizes it. + if (this.recapType === RecapsType.appointment) { + this.needs = this.utils.convertFiltersToModule(this.form.get('onlineDemarcheType').value); + } else { + this.needs = this.form.get('filters').value; + } this.beneficiary = { name: this.form.get('name').value, surname: this.form.get('surname').value, @@ -35,6 +46,9 @@ export class OrientationRecapComponent implements OnInit { case RecapsType.onlineMediation: this.handleOnlineOrientationRecap(); break; + case RecapsType.appointment: + this.handleAppointmentRecap(); + break; case RecapsType.structure: this.handleStructureRecap(); break; @@ -43,6 +57,15 @@ export class OrientationRecapComponent implements OnInit { } } + public shouldDisplayAppointmentRecap(): boolean { + return this.recapType === RecapsType.appointment; + } + + public handleAppointmentRecap(): void { + this.comment = this.form.get('details').value; + this.orientator = this.form.get('structureOrientator').value; + } + public handleStructureRecap(): void { this.comment = this.form.get('comments').value; this.structuresToPrint = this.form.get('structureChoice').value; @@ -50,10 +73,12 @@ export class OrientationRecapComponent implements OnInit { } public isOrientator(): boolean { - return this.orientator?.structureName ? true : false; + return !!this.orientator?.structureName; } public handleOnlineOrientationRecap(): void { + this.comment = this.form.get('comments').value; + this.orientator = this.form.get('structureOrientator').value; const monthNumber = parseInt(this.form.get('dateSlot').value.day.slice(-2)); const monthName = this.datePipe.transform(`2000-${monthNumber}-01`, 'MMMM', 'fr'); diff --git a/src/app/form/orientation-form-view/interfaces/onlineMediation.interface.ts b/src/app/form/orientation-form-view/interfaces/onlineMediation.interface.ts index fd27e71f06510b951afa1a8b79951e701fe53541..0e761600309233bec1bab2410567ff8a69605820 100644 --- a/src/app/form/orientation-form-view/interfaces/onlineMediation.interface.ts +++ b/src/app/form/orientation-form-view/interfaces/onlineMediation.interface.ts @@ -5,4 +5,6 @@ export interface IOnlineMediation { onlineDemarcheType: string[]; dateSlot: { day: string; hours: string }; preferredLanguage: string; + comment: string; + structureOrientator: { structureName: string; structureMail: string; structurePhone: string }; } diff --git a/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.html b/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.html index bc3b1a5f7d468fc58628193cd160f91634f24f80..5f82bce506350dfffccb88bff2884a07e1beeeaf 100644 --- a/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.html +++ b/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.html @@ -1,4 +1,5 @@ -<div *ngIf="hasStructure" class="container"> +<!-- Appointment success --> +<div *ngIf="!isOnlineMediation && hasStructure" class="container"> <img src="../../../../../../assets/form/structureCreated.svg" alt="rdv illustration" /> <h2>Votre demande de rendez-vous a été transmise !</h2> <p> @@ -11,7 +12,16 @@ <b>{{ structureRDV?.structureName || selectedStructureRDV?.structureName }}</b> </p> </div> -<div *ngIf="!hasStructure" class="container"> + +<!-- Hotline appointment success --> +<div *ngIf="isOnlineMediation" class="container"> + <img src="../../../../../../assets/form/structureCreated.svg" alt="rdv illustration" /> + <h2>Votre demande de médiation à distance a été transmise !</h2> + <p>La demande de <b>médiation à distance</b> a bien été transmise.</p> +</div> + +<!-- No structure found --> +<div *ngIf="!isOnlineMediation && !hasStructure" class="container"> <img src="../../../../../../assets/form/structureNegatif.svg" alt="rdv illustration" /> <h2>Aucune structure correspondant à votre recherche ne propose de rendez-vous</h2> <p>Merci de renouveler votre recherche avec des critères différents ou accédez à la cartographie</p> diff --git a/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.ts b/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.ts index b259b9fc9389e98fb2926eb4dd16a1344eb39773..9688588a2ac43ea9bde9fa414ceb4da901ca240b 100644 --- a/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.ts +++ b/src/app/form/orientation-form-view/online-demarch/appointment/appointment-end/appointment-end.component.ts @@ -12,9 +12,10 @@ import { OrientationService } from '../../../../../services/orientation.service' }) export class AppointmentEndComponent implements OnInit { @Input() form: UntypedFormGroup; - @Input() structureRDV: Structure; - @Input() socialWorker: Owner; - @Input() selectedStructureRDV: Structure; + @Input() structureRDV?: Structure; + @Input() socialWorker?: Owner; + @Input() selectedStructureRDV?: Structure; + @Input() isOnlineMediation = false; @Output() setResetOrientation = new EventEmitter(); @Output() checkValidation = new EventEmitter<any>(); diff --git a/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.html b/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.html index 551ec89f816c541e041141ff23a8a9cf4b09e5bb..de89d9d6af78055ea4b508b1a535c77cf61e79e0 100644 --- a/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.html +++ b/src/app/form/orientation-form-view/online-demarch/onlineDemarch-form.component.html @@ -25,12 +25,6 @@ [currentType]="currentType" (checkValidation)="checkValidation()" /> - <app-structure-orientator - *ngIf="currentStep === OnlineDemarchesAppointmentSteps.structureOrientator" - [profile]="profile" - [form]="form" - (validatePage)="checkValidation()" - /> <app-structure-pmr *ngIf="currentStep === OnlineDemarchesAppointmentSteps.pmrAccess" [structureForm]="form" @@ -66,6 +60,12 @@ [isOrientationRdv]="true" (checkValidation)="checkValidation()" /> + <app-structure-orientator + *ngIf="currentStep === OnlineDemarchesAppointmentSteps.structureOrientator" + [profile]="profile" + [form]="form" + (validatePage)="checkValidation()" + /> <app-appointment-end *ngIf="currentStep === OnlineDemarchesAppointmentSteps.rdvEnd" [form]="form" @@ -75,6 +75,14 @@ (checkValidation)="checkValidation()" (setResetOrientation)="showResetOrientation()" /> + <app-orientation-recap + *ngIf="currentStep === OnlineDemarchesAppointmentSteps.orientationRecap" + [form]="form" + [recapType]="RecapsType.appointment" + [socialWorker]="socialWorker" + [structureRDV]="structureRDV" + (checkValidation)="checkValidation()" + /> </ng-container> <!-- ONLINE MEDIATION FORM --> <ng-container *ngIf="currentType === OnlineDemarche.onlineMediation"> @@ -98,12 +106,36 @@ [form]="form" (checkValidation)="checkValidation()" /> + <app-orientation-comments + *ngIf="currentStep === HotlineMediationSteps.comments" + [form]="form" + (checkValidation)="checkValidation()" + /> + <app-structure-orientator + *ngIf="currentStep === HotlineMediationSteps.structureOrientator" + [profile]="profile" + [form]="form" + (validatePage)="checkValidation()" + /> <app-orientation-recap *ngIf="currentStep === HotlineMediationSteps.orientationRecap" [form]="form" [recapType]="RecapsType.onlineMediation" (checkValidation)="checkValidation()" /> + <app-appointment-end + *ngIf="currentStep === HotlineMediationSteps.rdvEnd" + [form]="form" + [isOnlineMediation]="true" + (checkValidation)="checkValidation()" + (setResetOrientation)="showResetOrientation()" + /> + <app-orientation-recap + *ngIf="currentStep === HotlineMediationSteps.orientationPrint" + [form]="form" + [recapType]="RecapsType.onlineMediation" + (checkValidation)="checkValidation()" + /> </ng-container> <!-- STRUCTURE LIST FORM --> <app-orientation-structure-list 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 1697d8c628d8de841a2e0bbbf53f0e7199be6bb8..05e2e1a6b856306b8ef1cf9f75757c752f2bba72 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 @@ -207,14 +207,15 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked const isOnlineMediationOrientationRecap = isOnlineDemarcheOrLearnSkills && this.currentType === OnlineDemarche.onlineMediation && - this.currentStep === HotlineMediationSteps.orientationRecap; + this.currentStep === HotlineMediationSteps.orientationPrint; const isStructureListOrientationRecap = this.currentType === OnlineDemarche.structureList && this.currentStep === StructuresListSteps.orientationRecap; - const isAppointmentRdvEnd = + const isAppointmentOrientationRecap = isOnlineDemarcheOrLearnSkills && this.currentType === OnlineDemarche.appointment && - this.currentStep === AppointmentSteps.rdvEnd; - this.isLastStep = isOnlineMediationOrientationRecap || isStructureListOrientationRecap || isAppointmentRdvEnd; + this.currentStep === AppointmentSteps.orientationRecap; + this.isLastStep = + isOnlineMediationOrientationRecap || isStructureListOrientationRecap || isAppointmentOrientationRecap; } /** @@ -242,13 +243,11 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked }; await lastValueFrom(this.orientationService.createOnlineMediation(toCreate)) .then(() => { - this.canDeactivate = true; this.notificationService.showSuccess('Votre démarche en ligne a bien été enregistrée'); }) .catch(() => { this.notificationService.showErrorPleaseRetry('Échec de la création de votre démarche en ligne'); - }) - .finally(() => this.printForm()); + }); } public printForm(): void { @@ -300,6 +299,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked this.setStepNumber(Object.keys(HotlineMediationSteps).length); this.onlineDemarcheForm = this.orientationUtils.createOnlineMediationForm( this.utils.convertFiltersToModule(this.filters), + this.orientator, ); break; default: @@ -415,12 +415,23 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked this.previousNeedType = this.needType; return; } - // Handle last screen Online appointment and print + // If no multiple structures, skip orientator + if ( + this.currentType === OnlineDemarche.onlineMediation && + this.currentStep === HotlineMediationSteps.structureOrientator - 1 + ) { + this.skipStructureOrientator(true); + } + // Handle Online appointment if ( this.currentType === OnlineDemarche.onlineMediation && - this.currentStep === HotlineMediationSteps.orientationRecap + this.currentStep === HotlineMediationSteps.rdvEnd - 1 ) { await this.handleOnlineAppointment(); + } + // Handle last screen Online appointment and print + if (this.currentStep === HotlineMediationSteps.orientationPrint) { + this.printForm(); return; } // Handle last screen appointment @@ -438,6 +449,10 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked // Structure list handling if (this.currentType === OnlineDemarche.structureList) { + // If no multiple structures, skip orientator + if (this.currentStep === StructuresListSteps.structureOrientator - 1) { + this.skipStructureOrientator(true); + } // Print last screen if (this.currentStep === StructuresListSteps.orientationRecap) { this.printForm(); @@ -451,7 +466,6 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked // Unset fullscreen if (this.currentStep === StructuresListSteps.structureChoice) { this.fullScreen = false; - this.skipStructureOrientator(true); } } @@ -485,7 +499,7 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked } // after last page, go to new orientation - if (this.currentStep === AppointmentSteps.rdvEnd) { + if (this.currentStep === AppointmentSteps.orientationRecap) { this.sendOrientationIndicator(this.structureOrientationForm ?? this.onlineDemarcheForm); history.pushState({ rdvStructure: null, rdvUser: null }, '', '/orientation'); window.location.reload(); @@ -541,9 +555,6 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked ) { this.currentStep--; } - if (this.currentStep === AppointmentSteps.structureOrientator + 1) { - this.skipStructureOrientator(false); - } if (this.indicatorNeedType === NeedsType.learnSkills && this.currentStep === AppointmentSteps.infoScreen + 1) { this.currentStep--; } @@ -561,6 +572,9 @@ export class OrientationFormViewComponent implements OnInit, AfterContentChecked this.currentStep -= 3; this.skipStructureOrientator(false); } + if (this.currentStep === AppointmentSteps.structureOrientator + 1) { + this.skipStructureOrientator(false); + } } // Default case for first form step. If there was a previous form (like filterForm) we go back to this form diff --git a/src/app/structure-list/models/filter.model.ts b/src/app/structure-list/models/filter.model.ts index 87f5b5ae4b7aac2f2c644b447b32a7891127ab3f..35bb660b7d2e0297201a42483505527da1590b25 100644 --- a/src/app/structure-list/models/filter.model.ts +++ b/src/app/structure-list/models/filter.model.ts @@ -5,7 +5,7 @@ export class Filter { checked: boolean; orOperator: boolean; - constructor(name: string, value: any, text?: string, orOperator = false) { + constructor(name: string, value: string, text?: string, orOperator = false) { this.name = name; this.value = value.toString(); this.text = text; diff --git a/src/app/utils/orientationUtils.ts b/src/app/utils/orientationUtils.ts index 5c0ea9283864032214bb8bcbf55a4fc24778f636..5057e49c1a309e51a4bca82c01ca626b7e85082b 100644 --- a/src/app/utils/orientationUtils.ts +++ b/src/app/utils/orientationUtils.ts @@ -47,7 +47,10 @@ export class OrientationUtils { }); } - public createOnlineMediationForm(onlineDemarcheType: Module[]): UntypedFormGroup { + public createOnlineMediationForm( + onlineDemarcheType: Module[], + orientatorForm?: FormGroup<StructureOrientator>, + ): UntypedFormGroup { return new UntypedFormGroup({ filters: new FormControl<Module[]>(onlineDemarcheType, Validators.required), name: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER)]), @@ -55,6 +58,8 @@ export class OrientationUtils { phone: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.PHONE)]), dateSlot: new UntypedFormControl(null, Validators.required), preferredLanguage: new UntypedFormControl(PreferredLanguages.french, Validators.required), + comments: new UntypedFormControl('', Validators.required), + structureOrientator: orientatorForm || this.createStructureOrientatorForm(), }); } @@ -152,9 +157,21 @@ export class OrientationUtils { pagesValidation[HotlineMediationSteps.mediationLanguageSelection] = { valid: true, }; + pagesValidation[HotlineMediationSteps.comments] = { + valid: true, + }; + pagesValidation[HotlineMediationSteps.structureOrientator] = { + valid: form.get('structureOrientator').valid, + }; pagesValidation[HotlineMediationSteps.orientationRecap] = { valid: true, }; + pagesValidation[HotlineMediationSteps.rdvEnd] = { + valid: true, + }; + pagesValidation[HotlineMediationSteps.orientationPrint] = { + valid: true, + }; updatePageValid(pagesValidation[step].valid); } @@ -171,13 +188,13 @@ export class OrientationUtils { pagesValidation[StructuresListSteps.structureChoice] = { valid: form.get('structureChoice').valid, }; - pagesValidation[StructuresListSteps.structureOrientator] = { - valid: form.get('structureOrientator').valid, - }; pagesValidation[StructuresListSteps.mediationBeneficiaryInfo] = { valid: form.get('name').valid && form.get('surname').valid, }; pagesValidation[StructuresListSteps.comments] = { valid: true }; + pagesValidation[StructuresListSteps.structureOrientator] = { + valid: form.get('structureOrientator').valid, + }; pagesValidation[StructuresListSteps.orientationRecap] = { valid: true }; updatePageValid(pagesValidation[step].valid); } @@ -191,9 +208,6 @@ export class OrientationUtils { pagesValidation[AppointmentSteps.infoScreen] = { valid: true, }; - pagesValidation[AppointmentSteps.structureOrientator] = { - valid: form.get('structureOrientator').valid, - }; pagesValidation[AppointmentSteps.pmrAccess] = { valid: form.get('pmrAccess').valid, }; @@ -214,9 +228,13 @@ export class OrientationUtils { (!form.get('phone').value || form.get('phone').valid) && (!form.get('email').value || form.get('email').valid), }; + pagesValidation[AppointmentSteps.structureOrientator] = { + valid: form.get('structureOrientator').valid, + }; pagesValidation[AppointmentSteps.rdvEnd] = { valid: true, }; + pagesValidation[AppointmentSteps.orientationRecap] = { valid: true }; updatePageValid(pagesValidation[step].valid); }