import { Injectable, inject } 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 apiService = inject(ApiService);

    private _apiDomain = '/skydive';

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

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

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

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