43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
|
import {Component} from "@angular/core";
|
||
|
import {ActivatedRoute, Router} from "@angular/router";
|
||
|
import {Award} from "../../models/model-interfaces";
|
||
|
import {AwardingService} from "../../services/awarding-service/awarding.service";
|
||
|
|
||
|
|
||
|
@Component({
|
||
|
templateUrl: './confirm-award.component.html',
|
||
|
styleUrls: ['./confirm-award.component.css'],
|
||
|
})
|
||
|
export class ConfirmAwardComponent {
|
||
|
awards: Award[];
|
||
|
|
||
|
constructor(private router: Router,
|
||
|
private route: ActivatedRoute,
|
||
|
private awardingService: AwardingService) {
|
||
|
}
|
||
|
|
||
|
ngOnInit() {
|
||
|
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
||
|
|
||
|
this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => {
|
||
|
this.awards = awards;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
confirm(award: Award, decision: boolean) {
|
||
|
const updateObject = {
|
||
|
_id: award._id,
|
||
|
confirmed: decision ? 1 : 2
|
||
|
};
|
||
|
|
||
|
this.awardingService.updateAward(updateObject).subscribe(res => {
|
||
|
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
||
|
this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => {
|
||
|
this.awards = awards;
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|