respond to review comments

pull/19024/head
John Harrington 3 months ago
parent edf5259dc3
commit 2ff46c045c
No known key found for this signature in database

@ -34,13 +34,7 @@
>
<span>{{ "viewSend" | i18n }} </span>
</button>
<button
bitButton
type="button"
buttonType="secondary"
[block]="true"
(click)="backToEmail.emit(); $event.preventDefault(); $event.stopPropagation()"
>
<button bitButton type="button" buttonType="secondary" [block]="true" (click)="onBackClick()">
<span>{{ "back" | i18n }}</span>
</button>
}

@ -28,35 +28,43 @@ export class SendAccessEmailComponent implements OnInit, OnDestroy {
readonly loading = input.required<boolean>();
readonly backToEmail = output<void>();
constructor() {
// Update validators when enterOtp changes
effect(() => {
const isOtpMode = this.enterOtp();
if (this.email && this.otp) {
if (isOtpMode) {
// In OTP mode: email is not required (already entered), otp is required
this.email.clearValidators();
this.otp.setValidators([Validators.required]);
} else {
// In email mode: email is required, otp is not required
this.email.setValidators([Validators.required]);
this.otp.clearValidators();
}
this.email.updateValueAndValidity();
this.otp.updateValueAndValidity();
}
});
}
constructor() {}
ngOnInit() {
this.email = new FormControl("", Validators.required);
this.otp = new FormControl("");
this.formGroup().addControl("email", this.email);
this.formGroup().addControl("otp", this.otp);
}
// Update validators when enterOtp changes
effect(() => {
const isOtpMode = this.enterOtp();
if (isOtpMode) {
// In OTP mode: email is not required (already entered), otp is required
this.email.clearValidators();
this.otp.setValidators([Validators.required]);
} else {
// In email mode: email is required, otp is not required
this.email.setValidators([Validators.required]);
this.otp.clearValidators();
}
this.email.updateValueAndValidity();
this.otp.updateValueAndValidity();
});
}
ngOnDestroy() {
this.formGroup().removeControl("email");
this.formGroup().removeControl("otp");
}
onBackClick() {
this.backToEmail.emit();
if (this.otp) {
this.otp.clearValidators();
this.otp.setValue("");
this.otp.setErrors(null);
this.otp.markAsUntouched();
this.otp.markAsPristine();
}
}
}

@ -92,14 +92,6 @@ export class SendAuthComponent implements OnInit {
onBackToEmail() {
this.enterOtp.set(false);
const otpControl = this.sendAccessForm.controls.otp;
if (otpControl) {
otpControl.clearValidators();
otpControl.setValue("");
otpControl.setErrors(null);
otpControl.markAsUntouched();
otpControl.markAsPristine();
}
this.updatePageTitle();
}

Loading…
Cancel
Save