Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BRS-309: Mandatory Phone number bug #310

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions src/app/registration/contact-form/contact-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export class ContactFormComponent implements OnInit {
phoneControl.setValue('');
}
});
this.myForm.get('enablePhone').valueChanges.subscribe((enablePhoneValue) => {
this.myForm.get('enablePhone').valueChanges.subscribe((enablePhone) => {
const phoneControl = this.myForm.get('phone');
if (enablePhoneValue) {
if (enablePhone) {
phoneControl.setValidators([Validators.required, this.phoneValidator]);
} else {
phoneControl.setValidators([Validators.required]);
Expand All @@ -111,8 +111,8 @@ export class ContactFormComponent implements OnInit {
lastName: ['', Validators.required],
email: ['', [Validators.required, Validators.pattern(Constants.emailValidationRegex)]],
emailCheck: ['', [Validators.required]],
phone: ['', [Validators.required]],
enablePhone: ['', [Validators.required]]
phone: [''],
enablePhone: [false]
},
{
validators: [this.checkMatchEmails('email', 'emailCheck'), this.checkPhoneNumber('phone', 'enablePhone') ],
Expand Down Expand Up @@ -192,16 +192,27 @@ export class ContactFormComponent implements OnInit {
}

submit(): void {
const combinedValue = this.dialCode + this.myForm.get('phone').value.number;
this.saving = true;
const obj = {
firstName: this.myForm.get('firstName').value,
lastName: this.myForm.get('lastName').value,
email: this.myForm.get('email').value,
phone: `+${this.justNumbers(combinedValue)}`,
captchaJwt: this.captchaJwt
};
if (this.myForm.get('enablePhone').value) {
const combinedValue = this.dialCode + this.myForm.get('phone').value.number;
this.saving = true;
const obj = {
firstName: this.myForm.get('firstName').value,
lastName: this.myForm.get('lastName').value,
email: this.myForm.get('email').value,
phone: `+${this.justNumbers(combinedValue)}`,
captchaJwt: this.captchaJwt
};
this.emitter.emit(obj);
} else {
this.saving = true;
const obj = {
firstName: this.myForm.get('firstName').value,
lastName: this.myForm.get('lastName').value,
email: this.myForm.get('email').value,
captchaJwt: this.captchaJwt
};
this.emitter.emit(obj);
}
}

captchaValidated(event): void {
Expand Down