Skip to content
Snippets Groups Projects
Commit b68b85ca authored by Adel LAKHDAR's avatar Adel LAKHDAR
Browse files

fix(UI): fix newsletter form

parent 8b122733
No related branches found
No related tags found
2 merge requests!846V3.1.0 (sans impression),!815fix(UI): fix newsletter form
...@@ -25,7 +25,6 @@ export class FooterFormComponent { ...@@ -25,7 +25,6 @@ export class FooterFormComponent {
@Input() nbPagesForm: number; @Input() nbPagesForm: number;
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
@Input() linkedStructureId: string[] = null; @Input() linkedStructureId: string[] = null;
@Input() acceptNewsletter: boolean;
@Input() currentStep: stepType; @Input() currentStep: stepType;
@Input() hasOtherPersonalOffer: boolean; @Input() hasOtherPersonalOffer: boolean;
@Input() isPersonalOfferProfile: boolean; @Input() isPersonalOfferProfile: boolean;
...@@ -102,7 +101,7 @@ export class FooterFormComponent { ...@@ -102,7 +101,7 @@ export class FooterFormComponent {
user.structuresLink = this.linkedStructureId; user.structuresLink = this.linkedStructureId;
try { try {
await firstValueFrom(this.authService.register(user)); await firstValueFrom(this.authService.register(user));
if (this.acceptNewsletter) { if (this.form.value.hasAcceptedNewsletter) {
this.newsletterService.subscribe(user.email).subscribe(); this.newsletterService.subscribe(user.email).subscribe();
} }
document.getElementsByClassName('page')[0].scrollTo(0, 0); document.getElementsByClassName('page')[0].scrollTo(0, 0);
......
...@@ -12,11 +12,7 @@ ...@@ -12,11 +12,7 @@
/> />
</ng-container> </ng-container>
<ng-container *ngIf="currentStep === accountFormStepEnum.accountNewsletter"> <ng-container *ngIf="currentStep === accountFormStepEnum.accountNewsletter">
<app-account-newsletter <app-account-newsletter [accountForm]="accountForm" [profile]="profile" (validateForm)="setValidationsForm()" />
[accountForm]="accountForm"
[profile]="profile"
(acceptNewsletter)="acceptReceiveNewsletter($event)"
/>
</ng-container> </ng-container>
<ng-container *ngIf="currentStep === accountFormStepEnum.confirmEmailSentInfo"> <ng-container *ngIf="currentStep === accountFormStepEnum.confirmEmailSentInfo">
<app-information-step [step]="accountFormStepEnum.confirmEmailSentInfo" [formType]="formType.account" /> <app-information-step [step]="accountFormStepEnum.confirmEmailSentInfo" [formType]="formType.account" />
......
...@@ -50,7 +50,7 @@ export class AccountFormComponent implements OnInit, OnChanges { ...@@ -50,7 +50,7 @@ export class AccountFormComponent implements OnInit, OnChanges {
this.accountForm.get('confirmPassword').valid, this.accountForm.get('confirmPassword').valid,
}; };
this.pagesValidation[accountFormStep.accountNewsletter] = { this.pagesValidation[accountFormStep.accountNewsletter] = {
valid: true, valid: this.accountForm.get('hasAcceptedNewsletter').value !== null,
}; };
this.pagesValidation[accountFormStep.confirmEmailSentInfo] = { this.pagesValidation[accountFormStep.confirmEmailSentInfo] = {
valid: true, valid: true,
...@@ -74,7 +74,4 @@ export class AccountFormComponent implements OnInit, OnChanges { ...@@ -74,7 +74,4 @@ export class AccountFormComponent implements OnInit, OnChanges {
const isPageValid = this.pagesValidation[this.currentStep].valid; const isPageValid = this.pagesValidation[this.currentStep].valid;
this.pageValid.emit(isPageValid); this.pageValid.emit(isPageValid);
} }
public acceptReceiveNewsletter(accept: boolean): void {
this.acceptNewsletter.emit(accept);
}
} }
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
[id]="'yes'" [id]="'yes'"
[label]="'Oui'" [label]="'Oui'"
[value]="true" [value]="true"
[selected]="userAcceptNewsletter" [selected]="accountForm.get('hasAcceptedNewsletter').value === true"
(click)="acceptReceiveNewsletter(true)" (click)="acceptReceiveNewsletter(true)"
/> />
<app-radio-option <app-radio-option
[id]="'no'" [id]="'no'"
[label]="'Non'" [label]="'Non'"
[value]="false" [value]="false"
[selected]="!userAcceptNewsletter" [selected]="accountForm.get('hasAcceptedNewsletter').value === false"
(click)="acceptReceiveNewsletter(false)" (click)="acceptReceiveNewsletter(false)"
/> />
</div> </div>
......
...@@ -9,11 +9,10 @@ import { User } from '../../../../models/user.model'; ...@@ -9,11 +9,10 @@ import { User } from '../../../../models/user.model';
export class AccountNewsletterComponent { export class AccountNewsletterComponent {
@Input() accountForm: UntypedFormGroup; @Input() accountForm: UntypedFormGroup;
@Input() profile: User; @Input() profile: User;
@Output() acceptNewsletter = new EventEmitter<any>(); @Output() validateForm = new EventEmitter<any>();
public userAcceptNewsletter = false;
public acceptReceiveNewsletter(accepts: boolean): void { public acceptReceiveNewsletter(accepts: boolean): void {
this.userAcceptNewsletter = accepts; this.accountForm.get('hasAcceptedNewsletter').setValue(accepts);
this.acceptNewsletter.emit(accepts); this.validateForm.emit();
} }
} }
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
[isAccountMode]="isAccountMode" [isAccountMode]="isAccountMode"
(goNext)="nextPage()" (goNext)="nextPage()"
(pageValid)="validatePage($event)" (pageValid)="validatePage($event)"
(acceptNewsletter)="acceptReceiveNewsletter($event)"
/> />
<app-profile-form <app-profile-form
*ngIf="formType[routeParam] === formType.profile" *ngIf="formType[routeParam] === formType.profile"
...@@ -66,7 +65,6 @@ ...@@ -66,7 +65,6 @@
[form]="currentForm" [form]="currentForm"
[linkedStructureId]="linkedStructureId" [linkedStructureId]="linkedStructureId"
[isValid]="isPageValid" [isValid]="isPageValid"
[acceptNewsletter]="userAcceptNewsletter"
[hasOtherPersonalOffer]="hasOtherPersonalOffer" [hasOtherPersonalOffer]="hasOtherPersonalOffer"
[isPersonalOfferProfile]="isPersonalOfferProfile" [isPersonalOfferProfile]="isPersonalOfferProfile"
[isEditMode]="isEditMode" [isEditMode]="isEditMode"
......
...@@ -37,7 +37,6 @@ export class FormViewComponent implements OnInit, AfterViewInit { ...@@ -37,7 +37,6 @@ export class FormViewComponent implements OnInit, AfterViewInit {
public formUtils = new FormUtils(); public formUtils = new FormUtils();
// Account Form // Account Form
public accountForm: UntypedFormGroup; public accountForm: UntypedFormGroup;
public userAcceptNewsletter: boolean;
// Profile Form // Profile Form
public profileForm: UntypedFormGroup; public profileForm: UntypedFormGroup;
public isPersonalOfferProfile = false; public isPersonalOfferProfile = false;
...@@ -214,6 +213,7 @@ export class FormViewComponent implements OnInit, AfterViewInit { ...@@ -214,6 +213,7 @@ export class FormViewComponent implements OnInit, AfterViewInit {
Validators.pattern(CustomRegExp.PASSWORD), // NOSONAR Validators.pattern(CustomRegExp.PASSWORD), // NOSONAR
]), ]),
confirmPassword: new UntypedFormControl(''), confirmPassword: new UntypedFormControl(''),
hasAcceptedNewsletter: new UntypedFormControl(null),
}, },
[MustMatch('password', 'confirmPassword')], [MustMatch('password', 'confirmPassword')],
); );
...@@ -235,10 +235,6 @@ export class FormViewComponent implements OnInit, AfterViewInit { ...@@ -235,10 +235,6 @@ export class FormViewComponent implements OnInit, AfterViewInit {
}); });
} }
public acceptReceiveNewsletter(isAccepted: boolean): void {
this.userAcceptNewsletter = isAccepted;
}
private createPersonalOfferForm(personalOffer: PersonalOffer): void { private createPersonalOfferForm(personalOffer: PersonalOffer): void {
this.personalOfferForm = new UntypedFormGroup({ this.personalOfferForm = new UntypedFormGroup({
categories: new UntypedFormGroup({ categories: new UntypedFormGroup({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment