import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

export interface ExternalTournamentServer {
  id: string;
  label: string;
  url: string;
}

export interface ExternalTournamentServerList {
  servers: ExternalTournamentServer[];
}

@Injectable({ providedIn: 'root' })
export class TournamentServerService {
  private readonly http = inject(HttpClient);
  private readonly base = '/api/tournament/servers';

  list(): Observable<ExternalTournamentServerList> {
    return this.http.get<ExternalTournamentServerList>(this.base);
  }
}
