import { Injectable } from "@angular/core";

@Injectable({
  providedIn: "root",
})
export class AuthService {
  private isLoggedIn: boolean = false;
  companyLocalStorage: any;

  constructor() {
    this.companyLocalStorage = JSON.parse(
      localStorage.getItem("companyData") || "{}"
    );
  }

  login(email: string, password: string): boolean {
    // Implement login logic here
    // Sets isLoggedIn to true if email and password satisfy conditions
    if (email.length > 6 && email.includes("@") && password.length > 4) {
      this.isLoggedIn = true;
      return true;
    }
    return false;
  }

  logout(): void {
    // Implement your logout logic here
    this.isLoggedIn = false;
  }

  isLoggedInMethod(): boolean {
    if (this.companyLocalStorage) {
      return true;
    } else {
      return false;
    }

    // return this.isLoggedIn;
  }
}
