import { Component, OnInit, ViewChild, Input } from '@angular/core'; import { TournamentFilterComponent } from 'src/app/shared/components/filters/tournament-filter/tournament-filter.component'; import { TournamentAvailabilitySummaryCollection, TournamentAvailabilitySummary } from 'tournee.businesslogic'; import { UserProfileService } from 'src/app/shared/services/user.profile.service'; import { AuthService } from 'src/app/shared/services/auth.service'; @Component({ selector: 'app-tournament-search-container', templateUrl: './tournament-search-container.component.html', styleUrls: ['./tournament-search-container.component.css'], providers: [ UserProfileService ] }) export class TournamentSearchContainerComponent implements OnInit { isWorking: boolean = false; @ViewChild('TournamentFilter') TournamentFilter: TournamentFilterComponent; @Input() FilterExpanded: boolean = true; Summaries: TournamentAvailabilitySummaryCollection; constructor(private _profile: UserProfileService, public auth: AuthService) { } ngOnInit() { } BindResults(results: TournamentAvailabilitySummaryCollection) { this.Summaries = results; } Save(tournament: TournamentAvailabilitySummary) { if (this.isWorking) { return; } this.isWorking = true; this._profile.save_tournament(tournament.tournament_id) .then(() => { this.auth.add_saved_tournament(tournament.tournament_id); this.isWorking = false; }) .catch((err) => { console.log(err); this.isWorking = false; }) } SaveTitle() { if (this.auth.loggedIn()) { return "Save for later" } return "Cannot save - not logged in" } }