Implementation of Better Error Handling on SignUp
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
.error-box {
|
.error-box {
|
||||||
background-color: #ff00001a;
|
background-color: #ff00001a;
|
||||||
min-width: 250px;
|
max-width: 320px;
|
||||||
display: flex;
|
display: flex;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 25px;
|
padding: 25px;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<app-popup [state]="popupState"
|
<app-popup [state]="state"
|
||||||
(stateChange)="onStateChange($event)"
|
(stateChange)="onStateChange($event)"
|
||||||
[ignoreClickOutside]="ignoreClickOutside">
|
[ignoreClickOutside]="ignoreClickOutside">
|
||||||
|
|
||||||
<div class="container overflow-hidden"
|
<div class="container m-0 overflow-hidden"
|
||||||
[@resizeContainerForErrorMessage]="hideErrorMessage()">
|
[@resizeContainerForErrorMessage]="hideErrorMessage()">
|
||||||
|
|
||||||
<app-error-box [errorMessage]="errorMessage"
|
<app-error-box [errorMessage]="errorMessage"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|||||||
import { MatIconRegistry } from '@angular/material/icon';
|
import { MatIconRegistry } from '@angular/material/icon';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { faLock, faUser } from '@fortawesome/free-solid-svg-icons';
|
import { faLock, faUser } from '@fortawesome/free-solid-svg-icons';
|
||||||
import {Subscription, timeout} from 'rxjs';
|
import {Subscription} from 'rxjs';
|
||||||
import { AuthService } from 'src/app/shared/auth/auth.service';
|
import { AuthService } from 'src/app/shared/auth/auth.service';
|
||||||
import { HttpError } from 'src/app/shared/model/httpError/httpError.model';
|
import { HttpError } from 'src/app/shared/model/httpError/httpError.model';
|
||||||
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
||||||
@@ -24,7 +24,7 @@ const GITHUB_LOGO_SVG = "assets/img/providers/github.svg";
|
|||||||
state('hide',
|
state('hide',
|
||||||
style({
|
style({
|
||||||
height: '100px',
|
height: '100px',
|
||||||
width: '370px',
|
width: '320px',
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
transition(
|
transition(
|
||||||
@@ -44,7 +44,7 @@ const GITHUB_LOGO_SVG = "assets/img/providers/github.svg";
|
|||||||
style({
|
style({
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
height: '100px',
|
height: '100px',
|
||||||
width: '340px',
|
width: '320px',
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
state('hide',
|
state('hide',
|
||||||
@@ -94,8 +94,6 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
@Output()
|
@Output()
|
||||||
stateChange = new EventEmitter<boolean>();
|
stateChange = new EventEmitter<boolean>();
|
||||||
|
|
||||||
popupState = false;
|
|
||||||
|
|
||||||
loginForm!: FormGroup;
|
loginForm!: FormGroup;
|
||||||
|
|
||||||
authSubject!: Subscription;
|
authSubject!: Subscription;
|
||||||
@@ -137,7 +135,6 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.popupState = this.state;
|
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +172,7 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private closePopup() {
|
private closePopup() {
|
||||||
this.popupState = false;
|
this.state = false;
|
||||||
this.loginForm.reset();
|
this.loginForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
<app-popup [state]="state"
|
<app-popup [state]="state"
|
||||||
(stateChange)="onStateChange($event)"
|
(stateChange)="onStateChange($event)"
|
||||||
[ignoreClickOutside]="ignoreClickOutside">
|
[ignoreClickOutside]="ignoreClickOutside">
|
||||||
{{errorMessage}}
|
|
||||||
<div class="container authentication-container">
|
|
||||||
|
<div class="container m-0 overflow-hidden"
|
||||||
|
[@resizeContainerForErrorMessage]="hideErrorMessage()">
|
||||||
|
|
||||||
|
<app-error-box [errorMessage]="errorMessage"
|
||||||
|
[@showErrorMessage]="showErrorMessage()">
|
||||||
|
</app-error-box>
|
||||||
|
|
||||||
|
<div class="container authentication-container"
|
||||||
|
[@hideAuthContainer]="hideErrorMessage()"
|
||||||
|
(@hideAuthContainer.done)="hideAuthContainer($event)">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 auth-body auth-body-form">
|
<div class="col-lg-6 auth-body auth-body-form">
|
||||||
<form [formGroup]="signupForm" (ngSubmit)="onSignUp()">
|
<form [formGroup]="signupForm" (ngSubmit)="onSignUp()">
|
||||||
@@ -70,4 +80,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</app-popup>
|
</app-popup>
|
||||||
@@ -9,6 +9,7 @@ import { HttpError } from 'src/app/shared/model/httpError/httpError.model';
|
|||||||
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
||||||
import UserChecker from 'src/app/shared/model/user/user.checker';
|
import UserChecker from 'src/app/shared/model/user/user.checker';
|
||||||
import { User } from 'src/app/shared/model/user/user.model';
|
import { User } from 'src/app/shared/model/user/user.model';
|
||||||
|
import {animate, animateChild, group, query, state, style, transition, trigger} from "@angular/animations";
|
||||||
|
|
||||||
|
|
||||||
const GOOGLE_LOGO_SVG = "assets/img/providers/google.svg";
|
const GOOGLE_LOGO_SVG = "assets/img/providers/google.svg";
|
||||||
@@ -17,7 +18,70 @@ const GITHUB_LOGO_SVG = "assets/img/providers/github.svg";
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-signup',
|
selector: 'app-signup',
|
||||||
templateUrl: './signup.component.html',
|
templateUrl: './signup.component.html',
|
||||||
styleUrls: ['./signup.component.css']
|
styleUrls: ['./signup.component.css'],
|
||||||
|
animations: [
|
||||||
|
trigger('resizeContainerForErrorMessage', [
|
||||||
|
state('hide',
|
||||||
|
style({
|
||||||
|
height: '100px',
|
||||||
|
width: '320px',
|
||||||
|
})
|
||||||
|
),
|
||||||
|
transition(
|
||||||
|
'show => hide',
|
||||||
|
group([
|
||||||
|
query(
|
||||||
|
"@*",
|
||||||
|
animateChild(),
|
||||||
|
{ optional: true }
|
||||||
|
),
|
||||||
|
animate('1s ease')
|
||||||
|
])
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
trigger('showErrorMessage', [
|
||||||
|
state('show',
|
||||||
|
style({
|
||||||
|
opacity: 1,
|
||||||
|
height: '100px',
|
||||||
|
width: '320px',
|
||||||
|
})
|
||||||
|
),
|
||||||
|
state('hide',
|
||||||
|
style({
|
||||||
|
opacity: 0,
|
||||||
|
height: '0px',
|
||||||
|
width: '0px',
|
||||||
|
})
|
||||||
|
),
|
||||||
|
transition(
|
||||||
|
'* => show',
|
||||||
|
animate(
|
||||||
|
'500ms ease-in'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
trigger('hideAuthContainer', [
|
||||||
|
state('hide',
|
||||||
|
style({
|
||||||
|
opacity: 0,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
transition(
|
||||||
|
'show => hide',
|
||||||
|
group([
|
||||||
|
query(
|
||||||
|
"@*",
|
||||||
|
animateChild(),
|
||||||
|
{ optional: true }
|
||||||
|
),
|
||||||
|
animate(
|
||||||
|
'250ms ease-out'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class SignupComponent implements OnInit {
|
export class SignupComponent implements OnInit {
|
||||||
|
|
||||||
@@ -36,6 +100,8 @@ export class SignupComponent implements OnInit {
|
|||||||
|
|
||||||
errorMessage!: string | null;
|
errorMessage!: string | null;
|
||||||
|
|
||||||
|
isShowErrorMessage = false;
|
||||||
|
|
||||||
_fullnameIcon = faFingerprint;
|
_fullnameIcon = faFingerprint;
|
||||||
|
|
||||||
_emailIcon = faEnvelope;
|
_emailIcon = faEnvelope;
|
||||||
@@ -110,5 +176,26 @@ export class SignupComponent implements OnInit {
|
|||||||
this.signupForm.reset();
|
this.signupForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public showErrorMessage(): string {
|
||||||
|
if (this.isShowErrorMessage) {
|
||||||
|
return "show";
|
||||||
|
}
|
||||||
|
return "hide";
|
||||||
|
}
|
||||||
|
|
||||||
|
public hideErrorMessage(): string {
|
||||||
|
if (!!this.errorMessage) {
|
||||||
|
return "hide";
|
||||||
|
}
|
||||||
|
return "show";
|
||||||
|
}
|
||||||
|
|
||||||
|
hideAuthContainer(event: any) {
|
||||||
|
if (event.toState === "hide") {
|
||||||
|
event.element.style.display = "none";
|
||||||
|
this.isShowErrorMessage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user