import {
  DashboardRepository,
  DriverData,
  RaceData,
  LeagueStandingData,
  ActivityData,
  FriendData,
} from '../../../../core/dashboard/application/ports/DashboardRepository';

export class InMemoryRaceRepository implements DashboardRepository {
  private drivers: Map<string, DriverData> = new Map();
  private upcomingRaces: Map<string, RaceData[]> = new Map();
  private leagueStandings: Map<string, LeagueStandingData[]> = new Map();
  private recentActivity: Map<string, ActivityData[]> = new Map();
  private friends: Map<string, FriendData[]> = new Map();

  async findDriverById(driverId: string): Promise<DriverData | null> {
    return this.drivers.get(driverId) || null;
  }

  async getUpcomingRaces(driverId: string): Promise<RaceData[]> {
    return this.upcomingRaces.get(driverId) || [];
  }

  async getLeagueStandings(driverId: string): Promise<LeagueStandingData[]> {
    return this.leagueStandings.get(driverId) || [];
  }

  async getRecentActivity(driverId: string): Promise<ActivityData[]> {
    return this.recentActivity.get(driverId) || [];
  }

  async getFriends(driverId: string): Promise<FriendData[]> {
    return this.friends.get(driverId) || [];
  }

  addDriver(driver: DriverData): void {
    this.drivers.set(driver.id, driver);
  }

  addUpcomingRaces(driverId: string, races: RaceData[]): void {
    this.upcomingRaces.set(driverId, races);
  }

  addLeagueStandings(driverId: string, standings: LeagueStandingData[]): void {
    this.leagueStandings.set(driverId, standings);
  }

  addRecentActivity(driverId: string, activities: ActivityData[]): void {
    this.recentActivity.set(driverId, activities);
  }

  addFriends(driverId: string, friends: FriendData[]): void {
    this.friends.set(driverId, friends);
  }

  clear(): void {
    this.drivers.clear();
    this.upcomingRaces.clear();
    this.leagueStandings.clear();
    this.recentActivity.clear();
    this.friends.clear();
  }
}
