From fbf7c314a46edc245180c515c1996074c737a825 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Fri, 2 Aug 2024 19:15:42 +0200 Subject: [PATCH] update form validation --- .../auth/register/register.component.html | 16 ++++++++++++++-- .../auth/register/register.component.scss | 11 +++++++++++ .../auth/register/register.component.ts | 17 +++++++++++++++-- .../src/app/components/home/home.component.ts | 3 +-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/components/auth/register/register.component.html b/frontend/src/app/components/auth/register/register.component.html index fb4fc9a..a5b9e7a 100644 --- a/frontend/src/app/components/auth/register/register.component.html +++ b/frontend/src/app/components/auth/register/register.component.html @@ -19,7 +19,11 @@ disabled required /> -
+
+ @if (!authData.params) { +

Click here to resend the registration email.

+ } +
@@ -47,6 +53,11 @@ [(ngModel)]="authData.passwordConfirm" pattern="[^<>]*" minlength="6" + [class.error-border]=" + authData.password !== authData.passwordConfirm && + passwordConfirm.touched + " + [disabled]="!authData.params" required />
@@ -58,7 +69,8 @@ diff --git a/frontend/src/app/components/auth/register/register.component.scss b/frontend/src/app/components/auth/register/register.component.scss index 148f486..9aef02e 100644 --- a/frontend/src/app/components/auth/register/register.component.scss +++ b/frontend/src/app/components/auth/register/register.component.scss @@ -49,6 +49,14 @@ section { font-size: 12px !important; font-weight: 400 !important; } + a { + color: $red; + text-decoration: underline; + cursor: pointer; + &:hover { + text-decoration: none; + } + } } .register-form { @@ -77,4 +85,7 @@ section { background-color: rgba($white, 0.1); } } + .error-border { + border: 1px solid red; + } } diff --git a/frontend/src/app/components/auth/register/register.component.ts b/frontend/src/app/components/auth/register/register.component.ts index 3b58e89..4cd7e14 100644 --- a/frontend/src/app/components/auth/register/register.component.ts +++ b/frontend/src/app/components/auth/register/register.component.ts @@ -1,21 +1,34 @@ import { Component } from '@angular/core'; import { BtnLargeComponent } from '../../../shared/components/btn-large/btn-large.component'; import { FormsModule, NgForm } from '@angular/forms'; +import { ActivatedRoute, RouterLink } from '@angular/router'; @Component({ selector: 'app-register', standalone: true, - imports: [BtnLargeComponent, FormsModule], + imports: [BtnLargeComponent, FormsModule, RouterLink], templateUrl: './register.component.html', styleUrl: './register.component.scss', }) export class RegisterComponent { authData = { - mail: 'test@test.de', + mail: '', + params: false, password: '', passwordConfirm: '', }; + constructor(private route: ActivatedRoute) {} + + ngOnInit(): void { + this.route.queryParams.subscribe((params) => { + this.authData.mail = params['mail'] || ''; + this.authData.mail + ? (this.authData.params = true) + : (this.authData.params = false); + }); + } + isUserEmailValid(emailValue: string) { const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/; return emailRegex.test(emailValue); diff --git a/frontend/src/app/components/home/home.component.ts b/frontend/src/app/components/home/home.component.ts index 1b6912f..289efa7 100644 --- a/frontend/src/app/components/home/home.component.ts +++ b/frontend/src/app/components/home/home.component.ts @@ -2,8 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { HeaderComponent } from './header/header.component'; import { FooterComponent } from './footer/footer.component'; import { AuthComponent } from '../auth/auth.component'; -import { Router, NavigationEnd, ActivatedRoute } from '@angular/router'; -import { filter } from 'rxjs/operators'; +import { ActivatedRoute } from '@angular/router'; import { RegisterComponent } from '../auth/register/register.component'; @Component({