48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import {Injectable} from '@angular/core';
|
|
import {AppConfig} from '../../app.config';
|
|
import {HttpClient} from '../http-client';
|
|
import {Promotion} from '../../models/model-interfaces';
|
|
|
|
@Injectable()
|
|
export class PromotionService {
|
|
|
|
hasUnprocessedPromotion = false;
|
|
|
|
constructor(private http: HttpClient,
|
|
private config: AppConfig) {
|
|
}
|
|
|
|
getUnconfirmedPromotions(fraction?: string) {
|
|
return this.http.get(this.config.apiPromotionPath + '?inProgress=true&fractFilter=' + fraction)
|
|
.map(res => res.json());
|
|
}
|
|
|
|
checkUnconfirmedPromotions(fraction?: string) {
|
|
this.getUnconfirmedPromotions(fraction).subscribe((items) => {
|
|
if (items.length > 0) {
|
|
this.hasUnprocessedPromotion = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
getSquadPromotions(squadId: string) {
|
|
return this.http.get(this.config.apiPromotionPath + '?squadId=' + squadId)
|
|
.map(res => res.json());
|
|
}
|
|
|
|
requestPromotion(promotion: Promotion) {
|
|
return this.http.post(this.config.apiPromotionPath, promotion);
|
|
}
|
|
|
|
updatePromotion(promotion) {
|
|
return this.http.patch(this.config.apiPromotionPath + '/' + promotion._id, promotion)
|
|
.map(res => res.json());
|
|
}
|
|
|
|
deletePromotion(promotionId) {
|
|
return this.http.delete(this.config.apiPromotionPath + promotionId);
|
|
}
|
|
|
|
}
|
|
|