diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 704c8d0..040a9e1 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,5 +1,8 @@ import { Routes } from '@angular/router'; +import { RegisterComponent } from './auth/pages/register/register.component'; -const routes: Routes = []; +const routes: Routes = [ + { path: 'register', component: RegisterComponent }, +]; export default routes; diff --git a/src/app/auth/pages/register/register.component.html b/src/app/auth/pages/register/register.component.html index 6b0ba2e..1b11288 100644 --- a/src/app/auth/pages/register/register.component.html +++ b/src/app/auth/pages/register/register.component.html @@ -1 +1,67 @@ -

register works!

+
+ +
+

Sign Up

+ +
+ +
+ + + Please input a valid email address! + +
+
+ +
+ +
+ + + Please input your password! + +
+
+ +
+ +
+ + + Please confirm your password! + +
+
+ +
+ + +
+
+
diff --git a/src/app/auth/pages/register/register.component.scss b/src/app/auth/pages/register/register.component.scss index e69de29..aaedafd 100644 --- a/src/app/auth/pages/register/register.component.scss +++ b/src/app/auth/pages/register/register.component.scss @@ -0,0 +1,43 @@ +.register-container { + display: flex; + justify-content: center; + height: 100%; + } + + .register-form { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 30rem; + height: auto; + margin: auto; + padding: 2rem; + background-color: rgba(199, 199, 199, 0.14); + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3); + + .register-title { + font-weight: 700; + margin-bottom: 1rem; + } + + .register-form-item { + margin-bottom: 1rem; + + .register-field { + display: flex; + flex-direction: column; + position: relative; + } + } + + .register-button-container { + display: flex; + gap: 1rem; + } + .register-success-message { + margin: auto; + position: absolute; + } + } + \ No newline at end of file diff --git a/src/app/auth/pages/register/register.component.ts b/src/app/auth/pages/register/register.component.ts index 7bb7c24..7e8cd0f 100644 --- a/src/app/auth/pages/register/register.component.ts +++ b/src/app/auth/pages/register/register.component.ts @@ -1,11 +1,59 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { CommonModule } from '@angular/common'; +import { InputTextModule } from 'primeng/inputtext'; +import { ButtonModule } from 'primeng/button'; +import { MessageService } from 'primeng/api'; +import { MessagesModule } from 'primeng/messages'; +import { MessageModule } from 'primeng/message'; +import { PasswordModule } from 'primeng/password'; @Component({ selector: 'app-register', standalone: true, - imports: [], + imports: [ + CommonModule, + ReactiveFormsModule, + InputTextModule, + ButtonModule, + MessagesModule, + MessageModule, + PasswordModule + ], templateUrl: './register.component.html', - styleUrl: './register.component.scss', + styleUrls: ['./register.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, + providers: [MessageService] }) -export class RegisterComponent {} +export class RegisterComponent { + public validateForm!: FormGroup; + + constructor( + private fb: FormBuilder, + private messageService: MessageService + ) { + this.validateForm = this.fb.group({ + email: ['', [Validators.email, Validators.required]], + password: ['', [Validators.required]], + confirm: ['', [Validators.required]], + }); + } + + public submitForm(): void { + if (this.validateForm.valid) { + // Perform registration logic here (e.g., send data to backend) + // console.log('submit', this.validateForm.value); + this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Registration successful!' }); + this.validateForm.reset(); + } else { + Object.values(this.validateForm.controls).forEach((control) => { + if (control.invalid) { + control.markAsDirty(); + control.updateValueAndValidity({ + onlySelf: true, + }); + } + }); + } + } +}