File
Metadata
changeDetection |
ChangeDetectionStrategy.Default |
selector |
roleame-webapp-invitations |
styleUrls |
invitations.component.scss |
templateUrl |
invitations.component.html |
Constructor
constructor(amplifyService: AmplifyService)
|
Methods
acceptInvitation
|
acceptInvitation(game: any)
|
Returns: void
|
rejectInvitation
|
rejectInvitation(game: any)
|
Returns: void
|
currentUser
|
currentUser: string
|
routeAnimationsElements
|
routeAnimationsElements: string
|
Default value: ROUTE_ANIMATIONS_ELEMENTS
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Game } from 'app/types/game';
import { AmplifyService } from 'aws-amplify-angular';
import { routeAnimations, ROUTE_ANIMATIONS_ELEMENTS } from '../../../core/core.module';
import { Player } from '../../../types/player';
@Component({
selector: 'roleame-webapp-invitations',
templateUrl: './invitations.component.html',
styleUrls: ['./invitations.component.scss'],
animations: [routeAnimations],
changeDetection: ChangeDetectionStrategy.Default
})
export class InvitationsComponent implements OnInit {
routeAnimationsElements = ROUTE_ANIMATIONS_ELEMENTS;
currentUser: string = '';
@Input()
invitations: Game[] = []
@Output()
accept = new EventEmitter<Player>();
@Output()
reject = new EventEmitter<Player>();
constructor(private amplifyService: AmplifyService) {
this.amplifyService.auth().currentAuthenticatedUser().then(user => {
this.currentUser = user.username;
}).catch(err => console.error(err));
}
acceptInvitation(game: Game){
var gameMember = game.players.find( gameMember => gameMember.playerID === this.currentUser)
gameMember.pendingInvite = false
this.accept.emit(gameMember)
}
rejectInvitation(game: Game){
this.reject.emit(game.players.find( gameMember => gameMember.playerID === this.currentUser))
}
ngOnInit() {
}
}