import {
  EHealthProblem,
  ESleepLevel,
  ESport,
  ESportLevel,
} from "./enums/Enums";

export class User {
  private _name: string;
  private _age: number | undefined;
  private _height: number | undefined;
  private _weight: number | undefined;
  private _sexe: boolean | undefined; // true = Male, false = Female
  private _logo: string | undefined;
  private _nbSessionPerWeek: number | undefined;
  private _goal: string | undefined;
  private _healthProblems: EHealthProblem[] | undefined;
  private _sport: ESport | undefined;
  private _sleepLevel: ESleepLevel | undefined;
  private _sportLevel: ESportLevel | undefined;
  private _email: string;
  private _password: string;

  constructor(
    name: string,
    age: number | undefined,
    height: number | undefined,
    weight: number | undefined,
    sexe: boolean | undefined,
    logo: string | undefined,
    nbSessionPerWeek: number | undefined,
    goal: string | undefined,
    healthProblems: EHealthProblem[] | undefined,
    sport: ESport | undefined,
    sleepLevel: ESleepLevel | undefined,
    sportLevel: ESportLevel | undefined,
    email: string,
    password: string
  ) {
    this._name = name;
    this._age = age;
    this._height = height;
    this._weight = weight;
    this._sexe = sexe;
    this._logo = logo;
    this._nbSessionPerWeek = nbSessionPerWeek;
    this._goal = goal;
    this._healthProblems = healthProblems;
    this._sport = sport;
    this._sleepLevel = sleepLevel;
    this._sportLevel = sportLevel;
    this._email = email;
    this._password = password;
  }

  // Getters
  get name(): string {
    return this._name;
  }

  get age(): number | undefined {
    return this._age;
  }

  get height(): number | undefined {
    return this._height;
  }

  get weight(): number | undefined {
    return this._weight;
  }

  get sexe(): boolean | undefined {
    return this._sexe;
  }

  get logo(): string | undefined {
    return this._logo;
  }

  get nbSessionPerWeek(): number | undefined {
    return this._nbSessionPerWeek;
  }

  get goals(): string | undefined {
    return this._goal;
  }

  get healthProblems(): EHealthProblem[] | undefined {
    return this._healthProblems;
  }

  get sports(): ESport | undefined {
    return this._sport;
  }

  get sleepLevel(): ESleepLevel | undefined {
    return this._sleepLevel;
  }

  get sportLevel(): ESportLevel | undefined {
    return this._sportLevel;
  }

  get email(): string {
    return this._email;
  }

  get password(): string {
    return this._password;
  }

  // Setters
  set name(value: string) {
    this._name = value;
  }

  set age(value: number | undefined) {
    this._age = value;
  }

  set height(value: number | undefined) {
    this._height = value;
  }

  set weight(value: number | undefined) {
    this._weight = value;
  }

  set sexe(value: boolean | undefined) {
    this._sexe = value;
  }

  set logo(value: string | undefined) {
    this._logo = value;
  }

  set nbSessionPerWeek(value: number | undefined) {
    this._nbSessionPerWeek = value;
  }

  set goals(value: string | undefined) {
    this._goal = value;
  }

  set healthProblems(value: EHealthProblem[] | undefined) {
    this._healthProblems = value;
  }

  set sports(value: ESport | undefined) {
    this._sport = value;
  }

  set sleepLevel(value: ESleepLevel | undefined) {
    this._sleepLevel = value;
  }

  set sportLevel(value: ESportLevel | undefined) {
    this._sportLevel = value;
  }

  set email(value: string) {
    this._email = value;
  }

  set password(value: string) {
    this._password = value;
  }

  public isQuizDone(): boolean {
    return (
      this._name !== undefined &&
      this._age !== undefined &&
      this._height !== undefined &&
      this._weight !== undefined &&
      this._sexe !== undefined &&
      this._nbSessionPerWeek !== undefined &&
      this._goal !== undefined &&
      this._healthProblems !== undefined &&
      this._sport !== undefined &&
      this._sleepLevel !== undefined &&
      this._sportLevel !== undefined
    );
  }

  static fromJSON(json: any): User {
    return new User(
      json._name,
      json._age,
      json._height,
      json._weight,
      json._sexe,
      json._logo,
      json._nbSessionPerWeek,
      json._goal,
      json._healthProblems,
      json._sport,
      json._sleepLevel,
      json._sportLevel,
      json._email,
      json._password
    );
  }
}
