import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';

import { ApiService } from './api.service';
import { AeronefsPageData, CanopiesPageData, DropZonesPageData, JumpsPageData } from '@models';

@Injectable({ providedIn: 'root' })
export class PagesService {
    private apiVersion = '/v1';
    constructor(
        private apiService: ApiService
    ) { }

    getAeronefsPage(): Observable<AeronefsPageData> {
        return this.apiService.get(`${this.apiVersion}/pages/aeronefs`).pipe(take(1));
    }

    getCanopiesPage(): Observable<CanopiesPageData> {
        return this.apiService.get(`${this.apiVersion}/pages/canopies`).pipe(take(1));
    }

    getDropZonesPage(): Observable<DropZonesPageData> {
        return this.apiService.get(`${this.apiVersion}/pages/dropzones`).pipe(take(1));
    }

    getJumpsPage(): Observable<JumpsPageData> {
        return this.apiService.get(`${this.apiVersion}/pages/jumps`).pipe(take(1));
    }

}
