diff --git a/src/app/features/auth/components/login/login.html b/src/app/features/auth/components/login/login.html index 49d79f3..13bfb17 100644 --- a/src/app/features/auth/components/login/login.html +++ b/src/app/features/auth/components/login/login.html @@ -1,4 +1,11 @@ -
+@if (successMessage) { +
+

{{successMessage}}

+
+} +
diff --git a/src/app/features/auth/components/login/login.ts b/src/app/features/auth/components/login/login.ts index a48adca..562780f 100644 --- a/src/app/features/auth/components/login/login.ts +++ b/src/app/features/auth/components/login/login.ts @@ -1,9 +1,18 @@ import { Component } from "@angular/core"; +import { Router, RouterLink } from "@angular/router"; @Component({ selector: "app-login", - imports: [], + imports: [RouterLink], templateUrl: "./login.html", styleUrl: "./login.css", }) -export class Login {} +export class Login { + successMessage: string | undefined; + + constructor(private router: Router) { + const navigator = this.router.currentNavigation(); + const state = navigator?.extras.state as { message?: string }; + this.successMessage = state?.message; + } +} diff --git a/src/app/features/auth/components/register/register.html b/src/app/features/auth/components/register/register.html index d246cda..5c50e7b 100644 --- a/src/app/features/auth/components/register/register.html +++ b/src/app/features/auth/components/register/register.html @@ -18,7 +18,7 @@ >
Name* - +
@@ -26,6 +26,7 @@ Mobile Number* City* - + @@ -67,7 +74,9 @@ - Already have an account ? Login diff --git a/src/app/features/auth/components/register/register.ts b/src/app/features/auth/components/register/register.ts index 23392d0..30ba022 100644 --- a/src/app/features/auth/components/register/register.ts +++ b/src/app/features/auth/components/register/register.ts @@ -3,15 +3,17 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angula import { AuthService } from "../../services/auth-service"; import { RegisterUserRequest } from "../../../../core/models/user.model"; import { Error } from "../../../../shared/components/error/error"; +import { Router, RouterLink } from "@angular/router"; @Component({ selector: "app-register", - imports: [ReactiveFormsModule, Error], + imports: [ReactiveFormsModule, Error, RouterLink], templateUrl: "./register.html", styleUrl: "./register.css", }) export class Register { authService = inject(AuthService); + router = inject(Router); errors = signal([]); registerForm = new FormGroup({ @@ -31,7 +33,8 @@ export class Register { } this.authService.register(this.registerForm.value as RegisterUserRequest).subscribe({ - next: () => console.log("success"), + next: () => + this.router.navigate(["/login"], { state: { message: "Registration successful!" } }), error: (error) => { const errors: Record = error?.error?.errors || {}; const errorMessages: string[] = Object.values(errors).flat();