import { User } from "@/model/User";
import { IUserService } from "./user.service.interface";

export class UserStubService implements IUserService {
  private readonly users: User[] = [
    new User(
      "Alice",
      28,
      165,
      58,
      false,
      "alice.png",
      3,
      "Perdre du poids",
      [],
      "YOGA",
      "GOOD",
      "BEGINNER",
      "test@1.com",
      "password1"
    ),
    new User(
      "Bob",
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      undefined,
      "test@2.com",
      "password2"
    ),
    new User(
      "Charlie",
      22,
      172,
      70,
      true,
      "charlie.png",
      2,
      "Se remettre en forme",
      [],
      "BIKING",
      "GOOD",
      "BEGINNER",
      "test@3.com",
      "password3"
    ),
    new User(
      "Diana",
      31,
      160,
      55,
      false,
      "diana.png",
      5,
      "Préparer un marathon",
      [],
      "RUNNING",
      "GOOD",
      "VERY_SPORTY",
      "test@4.com",
      "password4"
    ),
    new User(
      "Ethan",
      40,
      180,
      88,
      true,
      "ethan.png",
      1,
      "Maintenir sa forme",
      ["MIGRAINE"],
      "WALKING",
      "BAD",
      "SPORTY",
      "test@5.com",
      "password5"
    ),
    new User(
      "Fiona",
      26,
      167,
      62,
      false,
      "fiona.png",
      3,
      "Renforcer le dos",
      ["MIGRAINE"],
      "CARDIO",
      "BAD",
      "BEGINNER",
      "test@6.com",
      "password6"
    ),
    new User(
      "George",
      30,
      185,
      90,
      true,
      "george.png",
      4,
      "Perdre du gras",
      [],
      "BIKING",
      "TERRIBLE",
      "SPORTY",
      "test@7.com",
      "password7"
    ),
    new User(
      "Hanna",
      24,
      158,
      54,
      false,
      "hanna.png",
      2,
      "Se tonifier",
      [],
      "RANDO",
      "GOOD",
      "BEGINNER",
      "test@8.com",
      "password8"
    ),
    new User(
      "Ivan",
      50,
      175,
      95,
      true,
      "ivan.png",
      1,
      "Rééducation",
      ["ARTHROSE"],
      "WALKING",
      "BAD",
      "BEGINNER",
      "test@9.com",
      "password9"
    ),
    new User(
      "Julia",
      29,
      170,
      60,
      false,
      "julia.png",
      3,
      "Rester active",
      [],
      "ELSE",
      "GOOD",
      "SPORTY",
      "test@10.com",
      "password10"
    ),
  ];

  async login(email: string, password: string): Promise<User> {
    const user = this.users.find(
      (x) => x.email === email && x.password === password
    );

    if (!user) {
      throw new Error("No user.");
    }

    return user;
  }
}
