You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

90 lines
2.5 KiB

import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { ApiService } from '../../services/api.service';
import { Season, SeasonWeek, SeasonStandingsEntry } from '../../models/season';
import { AuthService } from 'src/app/services/auth-service';
import { NewRaceDialogComponent } from '../new-race-dialog/new-race-dialog.component';
import { UploadReplayDialogComponent } from '../upload-replay-dialog/upload-replay-dialog.component';
@Component({
selector: 'app-season-details',
templateUrl: './season-details.component.html',
styleUrls: ['./season-details.component.scss']
})
export class SeasonDetailsComponent {
seasonInfo?: Season;
seasonStandings?: SeasonStandingsEntry[];
weeks?: SeasonWeek[];
newRaceDetails = {
seasonId: '',
mapUID: '',
startDate: '',
endDate: '',
weekNumber: 0
};
constructor(
private route: ActivatedRoute,
private apiService: ApiService,
private authService: AuthService,
public dialog: MatDialog
)
{
}
isAuthenticated: boolean = false;
ngOnInit(): void {
this.isAuthenticated = this.authService.isAuthenticated();
const id = String(this.route.snapshot.paramMap.get('id'));
this.apiService.getSeasonDetails(id).subscribe(data => {
this.seasonInfo = (data as any).season;
this.weeks = (data as any).races;
this.seasonStandings = (data as any).standings;
console.log(data);
console.log(this.seasonInfo);
console.log(this.seasonStandings);
console.log(this.weeks);
});
}
openNewRaceDialog(): void {
if(this.seasonInfo)
{
this.newRaceDetails.seasonId = this.seasonInfo._id;
}
const dialogRef = this.dialog.open(NewRaceDialogComponent, {
width: '400px',
data: { ...this.newRaceDetails }
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
console.log('Follow details saved:', result);
// You can update your data or perform other actions here
} else {
console.log('Dialog canceled');
}
});
}
openUploadReplayDialog(seasonId: string): void {
const dialogRef = this.dialog.open(UploadReplayDialogComponent, {
width: '400px',
data: { seasonId: seasonId }
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
console.log('Follow details saved:', result);
// You can update your data or perform other actions here
} else {
console.log('Dialog canceled');
}
});
}
}