import { Injectable } from '@angular/core';
import { Router } from '@angular/router';

@Injectable({
  providedIn: 'root',
})
export class AuthService {
  private isLoggedIn = false;
  private readonly hardcodedUser = {
    email: 'user@test.com',
    password: 'password123',
  };

  constructor(private router: Router) {}

  login(email: string, password: string): boolean {
    if (
      email === this.hardcodedUser.email &&
      password === this.hardcodedUser.password
    ) {
      this.isLoggedIn = true;
      return true;
    }
    return false;
  }

  logout(): void {
    this.isLoggedIn = false;
    this.router.navigate(['/login']);
  }

  isAuthenticated(): boolean {
    return this.isLoggedIn;
  }
}
