Made tournament-players more standalone, now works from tournament screen

This commit is contained in:
Michel ten Voorde
2025-10-29 17:27:32 +01:00
parent 368aa53b9d
commit aacf06e203

View File

@@ -2,14 +2,13 @@ import {Component, inject, Input, OnInit} from '@angular/core';
import {CurrencyPipe} from "@angular/common";
import {MatSlideToggle, MatSlideToggleChange} from "@angular/material/slide-toggle";
import {TournamentService} from "../../service/tournament.service";
import {ActivatedRoute, Router} from "@angular/router";
import {ActivatedRoute} from "@angular/router";
import {Tournament} from "../../model/tournament";
import {FormsModule} from "@angular/forms";
import {MatSnackBar} from "@angular/material/snack-bar";
import {MatIcon} from "@angular/material/icon";
import {MatIconButton} from "@angular/material/button";
import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
import {CourtSelectionComponent} from "../court-selection/court-selection.component";
import {MatDialog} from "@angular/material/dialog";
import {SubstituteSelectionComponent} from "../substitute-selection/substitute-selection.component";
import {TournamentPlayer} from "../../model/tournamentPlayer";
@@ -34,15 +33,27 @@ import {MatTab, MatTabGroup, MatTabLabel} from "@angular/material/tabs";
standalone: true,
styleUrl: './tournament-players.component.scss'
})
export class TournamentPlayersComponent {
export class TournamentPlayersComponent implements OnInit {
@Input() tournament: Tournament;
constructor(
private tournamentService: TournamentService,
private route: ActivatedRoute,
private _snackBar: MatSnackBar,
) {}
ngOnInit() {
if (!this.tournament) {
const id = Number(this.route.snapshot.paramMap.get('id'));
if (id) {
this.tournamentService.getById(Number(id)).subscribe(data => {
this.tournament = data;
});
}
}
}
playerPaid($event: MatSlideToggleChange, playerId: number) {
this.tournamentService.playerPaid(this.tournament.id, playerId, $event.checked).subscribe(() => {
this._snackBar.open('Opgeslagen.');