update registration process

This commit is contained in:
Chneemann 2024-08-02 23:02:13 +02:00
parent 9ffe232895
commit 5aca18a217
9 changed files with 79 additions and 15 deletions

View file

@ -8,7 +8,7 @@
id="form" id="form"
class="register-form" class="register-form"
#taskForm="ngForm" #taskForm="ngForm"
(ngSubmit)="onSubmit(taskForm)" (ngSubmit)="onSubmit(taskForm, mail)"
onsubmit="return false" onsubmit="return false"
> >
<input <input
@ -20,8 +20,17 @@
class="custom-input" class="custom-input"
autocomplete="email" autocomplete="email"
[(ngModel)]="authData.mail" [(ngModel)]="authData.mail"
[ngClass]="{ 'error-border': mail.invalid && mail.touched }"
required required
/> />
<div class="error-msg">
@if (!mail.valid && mail.touched) {
<p>Please enter your email</p>
} @else { @if (mail.touched && authData.mail.length > 0 &&
!isUserEmailValid(authData.mail.toLowerCase())) {
<p>This is not a valid email format</p>
}}
</div>
<app-btn-large <app-btn-large
[value]="'Sign Up'" [value]="'Sign Up'"
[disabled]="!isUserEmailValid(authData.mail) && authData.mail.length > 0" [disabled]="!isUserEmailValid(authData.mail) && authData.mail.length > 0"

View file

@ -42,6 +42,7 @@ section {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
position: relative;
width: 500px; width: 500px;
padding: 24px; padding: 24px;
input { input {
@ -64,4 +65,27 @@ section {
background-color: rgba($white, 0.1); background-color: rgba($white, 0.1);
} }
} }
.error-border {
border: 2px solid $red;
color: $red;
&::placeholder {
color: $red;
}
}
}
.error-msg {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
bottom: 0;
height: 24px;
padding: 6px;
width: 62%;
p {
color: $red;
font-size: 12px !important;
font-weight: 400 !important;
}
} }

View file

@ -2,11 +2,12 @@ import { Component } from '@angular/core';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { BtnLargeComponent } from '../../shared/components/btn-large/btn-large.component'; import { BtnLargeComponent } from '../../shared/components/btn-large/btn-large.component';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { CommonModule } from '@angular/common';
@Component({ @Component({
selector: 'app-auth', selector: 'app-auth',
standalone: true, standalone: true,
imports: [BtnLargeComponent, FormsModule], imports: [CommonModule, BtnLargeComponent, FormsModule],
templateUrl: './auth.component.html', templateUrl: './auth.component.html',
styleUrl: './auth.component.scss', styleUrl: './auth.component.scss',
}) })
@ -22,11 +23,13 @@ export class AuthComponent {
return emailRegex.test(emailValue); return emailRegex.test(emailValue);
} }
onSubmit(ngForm: NgForm) { onSubmit(ngForm: NgForm, mailInput: any) {
if (ngForm.submitted && ngForm.form.valid) { if (ngForm.submitted && ngForm.form.valid) {
const queryParams = { mail: this.authData.mail }; const queryParams = { mail: this.authData.mail };
this.router.navigate(['/register'], { queryParams }); this.router.navigate(['/register'], { queryParams });
ngForm.form.reset(); ngForm.form.reset();
} else {
mailInput.control.markAsTouched();
} }
} }
} }

View file

@ -14,7 +14,7 @@ section {
height: 100vh; height: 100vh;
text-align: center; text-align: center;
background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
url(./../../../../assets/img/backgrounds/register.png); url(./../../../../assets/img/backgrounds/login.png);
background-size: cover; background-size: cover;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;

View file

@ -1,6 +1,18 @@
<section> <section>
<div class="content"> <div
class="content"
[ngStyle]="{ height: registrationSuccess ? '200px' : '492px' }"
>
<div class="headline">Sign Up</div> <div class="headline">Sign Up</div>
@if (registrationSuccess) {
<div class="reg-success">
<p>
Please check your email to confirm your email address and complete the
registration process.
</p>
<a href="/login">To the login</a>
</div>
} @else {
<form <form
id="form" id="form"
class="register-form" class="register-form"
@ -90,5 +102,6 @@
" "
></app-btn-large> ></app-btn-large>
</form> </form>
}
</div> </div>
</section> </section>

View file

@ -37,6 +37,25 @@ section {
} }
} }
.reg-success {
p {
color: $black;
font-size: 18px;
font-weight: 400;
margin: 36px 0 24px 0;
}
a {
font-size: 18px;
font-weight: 700;
color: $blue;
text-decoration: none;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
}
.error-msg { .error-msg {
display: flex; display: flex;
align-items: center; align-items: center;
@ -49,14 +68,6 @@ section {
font-size: 12px !important; font-size: 12px !important;
font-weight: 400 !important; font-weight: 400 !important;
} }
a {
color: $red;
text-decoration: underline;
cursor: pointer;
&:hover {
text-decoration: none;
}
}
} }
.register-form { .register-form {

View file

@ -2,11 +2,12 @@ import { Component } from '@angular/core';
import { BtnLargeComponent } from '../../../shared/components/btn-large/btn-large.component'; import { BtnLargeComponent } from '../../../shared/components/btn-large/btn-large.component';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { ActivatedRoute, RouterLink } from '@angular/router'; import { ActivatedRoute, RouterLink } from '@angular/router';
import { CommonModule } from '@angular/common';
@Component({ @Component({
selector: 'app-register', selector: 'app-register',
standalone: true, standalone: true,
imports: [BtnLargeComponent, FormsModule, RouterLink], imports: [CommonModule, BtnLargeComponent, FormsModule, RouterLink],
templateUrl: './register.component.html', templateUrl: './register.component.html',
styleUrl: './register.component.scss', styleUrl: './register.component.scss',
}) })
@ -17,6 +18,8 @@ export class RegisterComponent {
passwordConfirm: '', passwordConfirm: '',
}; };
registrationSuccess: boolean = false;
constructor(private route: ActivatedRoute) {} constructor(private route: ActivatedRoute) {}
ngOnInit(): void { ngOnInit(): void {
@ -34,6 +37,7 @@ export class RegisterComponent {
if (ngForm.submitted && ngForm.form.valid) { if (ngForm.submitted && ngForm.form.valid) {
console.log(this.authData); console.log(this.authData);
ngForm.form.reset(); ngForm.form.reset();
this.registrationSuccess = true;
} }
} }
} }

View file

@ -3,7 +3,7 @@
.btn { .btn {
padding: 12px 24px; padding: 12px 24px;
width: fit-content; width: fit-content;
box-shadow: 1px 1px 3px $black; box-shadow: 1px 1px 3px rgba($black, 0.5);
border-radius: 24px; border-radius: 24px;
color: $white; color: $white;
background-color: $blue; background-color: $blue;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,000 KiB