import { Component } from '@angular/core'; import { Router, RouterModule } from '@angular/router'; import { AuthService } from '../../cores/services/auth.service'; import { FormsModule } from '@angular/forms'; import { LoginData } from '../../cores/interface/auth'; import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-auth', standalone: true, imports: [FormsModule, RouterModule], templateUrl: './auth.component.html', styleUrls: ['./auth.component.scss'] }) export class AuthComponent { email: string = ''; password: string = ''; rememberMe: boolean = false; constructor(private authService: AuthService, private router: Router, private toastr: ToastrService) {} onSubmit() { const loginData: LoginData = { email: this.email, password: this.password, rememberMe: this.rememberMe }; this.authService.login(loginData).subscribe( (response) => { this.authService.saveTokens(response.data.token); this.router.navigate(['/dashboard']); this.toastr.success('Login successful'); }, (error) => { this.toastr.error(error.error.message); } ); } }