import { Injectable, inject } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { ApiService } from '../api.service';
import { DropZoneByOaci, DropZoneByYear } from '@models';

@Injectable({ providedIn: 'root' })
export class DropZonesService {
    private apiService = inject(ApiService);

    private _apiDomain = '/skydive';

    getAllByOaci(): Observable<Array<DropZoneByOaci>> {
        return this.apiService.get(`${this._apiDomain}/dropzones/allByOaci`).pipe(map((data) => data.dropzones));
    }

    getAllByOaciByYear(): Observable<Array<DropZoneByYear>> {
        return this.apiService.get(`${this._apiDomain}/dropzones/allByOaciByYear`).pipe(map((data) => data.dropzones));
    }
}
