@@ -38,10 +38,10 @@ export class TournamentService {
38
38
) ) ;
39
39
}
40
40
41
- getTournamentTeams ( id : number | string ) {
41
+ getTournamentTeams ( id : number | string , name : string ) {
42
42
return this . http . get ( BASE_URL + id + "/teams" , { withCredentials : true } ) . pipe ( map (
43
- response => response as Team [ ] ,
44
- error => console . error ( 'Unexpected Error on getTournamentTeams' )
43
+ response => participantsMapping ( response as Team [ ] , name ) ,
44
+ _error => console . error ( 'Unexpected Error on getTournamentTeams' )
45
45
) )
46
46
}
47
47
@@ -53,10 +53,6 @@ export class TournamentService {
53
53
}
54
54
55
55
createTournament ( Tournament : Tournament ) {
56
-
57
- // let To : Tournament;
58
- // To={owner:"owner",tournamentName:"tournamentName",numParticipants:1,numSignedUp:0,rounds:0,about:"about",ruleset:"ruleset",
59
- // location:"location", inscriptionDate:"2022-12-16T16:00",startDate:"2022-12-16T16:00" }
60
56
return this . http . post ( BASE_URL , Tournament , { withCredentials : true } ) . subscribe ( ( _resp : any ) => {
61
57
console . log ( "Creation Tournament: Successfully" ) ;
62
58
this . router . navigate ( [ '' ] ) ;
@@ -123,16 +119,13 @@ function errorIgnore(error: any, errorNum: number, funcName: string) {
123
119
124
120
//Didnt work, idk. Should debug to know
125
121
126
- // function participantsMapping(teamList: Team[]): [Team[], boolean] {
127
- // let isSigned = false;
128
- // if (this.loginService.isLogged()) {
129
- // let name = this.loginService.currentUser().name;
130
- // for (let i = 0; i < teamList.length; i++){
131
- // if (teamList[i].userA.name == name || teamList[i].userB.name == name){
132
- // isSigned = true;
133
- // }
134
- // }
135
- // }
136
- // return [teamList, isSigned]
137
- // }
122
+ function participantsMapping ( teamList : Team [ ] , name : string ) : [ Team [ ] , boolean ] {
123
+ let isSigned = false ;
124
+ for ( let i = 0 ; i < teamList . length ; i ++ ) {
125
+ if ( teamList [ i ] . userA . name == name || teamList [ i ] . userB . name == name ) {
126
+ isSigned = true ;
127
+ }
128
+ }
129
+ return [ teamList , isSigned ]
130
+ }
138
131
0 commit comments