remove toast error on invalid form for Browser/Desktop

This commit is contained in:
rr-bw 2024-09-10 14:22:51 -07:00
parent d098ee0cbc
commit 9588148e48
No known key found for this signature in database
GPG Key ID: 3FA13C3ADEE51D5D
2 changed files with 18 additions and 8 deletions

View File

@ -12,7 +12,7 @@
--> -->
<form <form
[ngClass]="{ 'tw-hidden': clientType !== ClientType.Web }" [ngClass]="{ 'tw-hidden': clientType !== ClientType.Web }"
[bitSubmit]="submit.bind(null, false)" [bitSubmit]="submit"
[formGroup]="formGroup" [formGroup]="formGroup"
> >
<!------------------------- <!-------------------------

View File

@ -142,20 +142,30 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
this.destroy$.complete(); this.destroy$.complete();
} }
submit = async (showToast = true): Promise<void> => { submit = async (): Promise<void> => {
const data = this.formGroup.value; const data = this.formGroup.value;
await this.setupCaptcha(); await this.setupCaptcha();
/**
* TODO-rr-bw: Verify the following
*
* In the original base login component there is a comment in the submit() method that says:
* "desktop, browser; This should be removed once all clients use reactive forms"
*
* Since we are now using reactive forms for all clients. I removed the Browser/Desktop specific
* toast error message.
*
* I also removed the `showToast` parameter from the submit() method entirely because my
* understanding is that now all errors will be visually handled by the reactive form via
* this.formGroup.markAllAsTouched()
*
* Therefore below I am simply checking if the form is invalid and returning if so.
*/
this.formGroup.markAllAsTouched(); this.formGroup.markAllAsTouched();
if (this.formGroup.invalid) {
// Web specific (start)
if (this.formGroup.invalid && !showToast) {
return; return;
} }
// Web specific (end)
// TODO-rr-bw: handle toast here for Browser/Desktop? See base LoginComponent -> submit()
const credentials = new PasswordLoginCredentials( const credentials = new PasswordLoginCredentials(
data.email, data.email,