From 55b9bdf68c6200804df73fd3d38805b51a8cf2b6 Mon Sep 17 00:00:00 2001 From: "Lala, Shahd" Date: Wed, 10 Jun 2026 17:16:49 +0000 Subject: [PATCH] fix: build errors --- src/app/models/tournament.models.ts | 42 +++++++++++++------------- src/app/services/bot.service.ts | 9 ++++-- src/app/services/tournament.service.ts | 6 ++-- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/app/models/tournament.models.ts b/src/app/models/tournament.models.ts index b9ef3e1..7dc854c 100644 --- a/src/app/models/tournament.models.ts +++ b/src/app/models/tournament.models.ts @@ -1,48 +1,48 @@ -export interface BotRef { - id: string; - name: string; -} - -export interface Clock { +export interface TournamentClock { limit: number; increment: number; } -export interface Variant { +export interface TournamentVariant { key: string; name: string; } -export interface ResultDto { +export interface TournamentBotRef { + id: string; + name: string; +} + +export interface TournamentResult { rank: number; points: number; tieBreak: number; - bot: BotRef; + bot: TournamentBotRef; nbGames: number; wins: number; draws: number; losses: number; } -export interface Standing { +export interface TournamentStanding { page: number; - players: ResultDto[]; + players: TournamentResult[]; } export interface Tournament { id: string; fullName: string; - clock: Clock; - variant: Variant; + clock: TournamentClock; + variant: TournamentVariant; rated: boolean; nbPlayers: number; nbRounds: number; createdBy: string; startsAt: string | null; - status: string; + status: 'created' | 'started' | 'finished'; round: number; - standing: Standing; - winner: BotRef | null; + standing: TournamentStanding; + winner: TournamentBotRef | null; } export interface TournamentList { @@ -51,16 +51,16 @@ export interface TournamentList { finished: Tournament[]; } -export interface Pairing { +export interface TournamentPairing { id: string; round: number; - white: BotRef | null; - black: BotRef; + white: TournamentBotRef | null; + black: TournamentBotRef; gameId: string | null; - winner: string | null; + winner: 'white' | 'black' | 'draw' | null; } export interface RoundPairings { round: number; - pairings: Pairing[]; + pairings: TournamentPairing[]; } diff --git a/src/app/services/bot.service.ts b/src/app/services/bot.service.ts index 0d7b558..fa77c29 100644 --- a/src/app/services/bot.service.ts +++ b/src/app/services/bot.service.ts @@ -1,12 +1,12 @@ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { Observable } from 'rxjs'; +import { Observable, map } from 'rxjs'; import { Bot, BotWithToken } from '../models/bot.models'; @Injectable({ providedIn: 'root' }) export class BotService { private readonly http = inject(HttpClient); - private readonly base = '/api/account/official-bots'; + private readonly base = '/api/account/bots'; list(): Observable { return this.http.get(this.base); @@ -16,6 +16,11 @@ export class BotService { return this.http.post(this.base, { name }); } + rotateToken(botId: string): Observable { + return this.http.post<{ token: string }>(`${this.base}/${botId}/rotate-token`, null) + .pipe(map(r => r.token)); + } + delete(botId: string): Observable { return this.http.delete(`${this.base}/${botId}`); } diff --git a/src/app/services/tournament.service.ts b/src/app/services/tournament.service.ts index 289a27d..493d400 100644 --- a/src/app/services/tournament.service.ts +++ b/src/app/services/tournament.service.ts @@ -40,8 +40,10 @@ export class TournamentService { return this.http.post(`${this.base}/${id}/start`, null); } - join(id: string, botId: string, botName: string): Observable { - return this.http.post(`${this.base}/${id}/join`, { botId, botName }); + joinWithBotToken(id: string, botToken: string): Observable { + return this.http.post(`${this.base}/${id}/join`, null, { + headers: new HttpHeaders({ Authorization: `Bearer ${botToken}` }) + }); } roundPairings(id: string, round: number): Observable {