Add the jump type in the tunnel flight

This commit is contained in:
Sébastien ANDRE
2023-08-17 11:28:31 +02:00
parent fe7ffa9016
commit 06f569c4d4
6 changed files with 53 additions and 12 deletions

View File

@@ -6,19 +6,23 @@ import { map } from "rxjs/operators";
import { TunnelFlightReq, TunnelFlightResp, TunnelFlight, TunnelFlightByMonthResp, TunnelFlightByMonth } from "../models/tunnel-flight";
import { DropZoneResp } from '../models/dropzone';
import { JumpTypeResp } from '../models/jumpType';
import { BaseService } from "./base.service";
import { DropzoneService } from "./dropzone.service";
import { JumpTypeService } from "./jump-type.service";
@Injectable()
export class TunnelFlightService extends BaseService {
constructor(private http: HttpClient,
private datePipe: DatePipe,
private jumpTypeService: JumpTypeService,
private dropzoneService: DropzoneService) {
super();
}
public addFlight(selectedTunnel: number,
selectedJumpType: number,
flightDate: Date,
nbMinutes: number,
comment: string) {
@@ -26,6 +30,7 @@ export class TunnelFlightService extends BaseService {
const bodyNewFlight: TunnelFlightReq = {
id: 0,
tunnelId: selectedTunnel,
jumpTypeId: selectedJumpType,
flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"),
notes: comment,
nbMinutes: nbMinutes
@@ -61,10 +66,13 @@ export class TunnelFlightService extends BaseService {
private mapWithDataInCache(apiResp: Array<TunnelFlightResp>): Array<TunnelFlight> {
let allDropzones: Array<DropZoneResp>;
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
let allJumpType: Array<JumpTypeResp>;
this.jumpTypeService.getFromCache().subscribe(data => { allJumpType = data; });
return apiResp.map((data) => {
let tmp = new TunnelFlight(data);
tmp.tunnel = allDropzones.find(d => d.id == data.tunnelId);
tmp.jumpType = allJumpType.find(d => d.id == data.jumpTypeId);
return tmp;
});