diff --git a/src/app/components/tournament-players/tournament-players.component.ts b/src/app/components/tournament-players/tournament-players.component.ts index f3b353a..6b89911 100644 --- a/src/app/components/tournament-players/tournament-players.component.ts +++ b/src/app/components/tournament-players/tournament-players.component.ts @@ -77,8 +77,11 @@ export class TournamentPlayersComponent implements OnInit { minHeight: '250px' }).afterClosed().subscribe(result => { if (result != undefined) { - console.log('Substitute selected for ' + player.name + ', namely: ' + result.substitute.name); - this.tournamentService.playerSubstitute(this.tournament.id, player.playerId, result.substitute.playerId).subscribe(data => { + console.log('Substitutes selected for ' + player.name + ': '); + console.log(result.substitutions); + console.log(result.substitutions[0].event + ': ' + result.substitutions[0].substitute); + console.log(result.substitutions[1].event + ': ' + result.substitutions[1].substitute); + this.tournamentService.playerSubstitute(this.tournament.id, player.playerId, result.substitutions).subscribe(data => { this.tournament = data; }); } diff --git a/src/app/service/tournament.service.ts b/src/app/service/tournament.service.ts index 9c538b1..3359544 100644 --- a/src/app/service/tournament.service.ts +++ b/src/app/service/tournament.service.ts @@ -5,6 +5,7 @@ import {Tournament} from "../model/tournament"; import {TournamentValidation} from "../model/tournamentValidation"; import {Result} from "../model/result"; import { environment } from "../../environments/environment" +import {TournamentPlayerSubstitution} from "../model/tournamentPlayer"; @Injectable({ providedIn: 'root' @@ -92,8 +93,8 @@ export class TournamentService { return this.http.patch(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/present/${paid}`, null); } - public playerSubstitute(tournamentId: number, playerId: number, substituteId: number): Observable { - return this.http.post(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitute/${substituteId}`, null) + public playerSubstitute(tournamentId: number, playerId: number, substitutions: TournamentPlayerSubstitution[]): Observable { + return this.http.post(`${this.tournamentsUrl}/${tournamentId}/players/${playerId}/substitutions`, substitutions) } public addTestData(): Observable {