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

import { ApiService } from '../api.service';
import { AeronefByImat, AeronefByYear } from '@models';

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

    private _apiDomain = '/skydive';

    getAllByImat(): Observable<Array<AeronefByImat>> {
        return this.apiService.get(`${this._apiDomain}/aeronefs/allByImat`).pipe(map((data) => data.aeronefs));
    }

    getAllByImatByYear(): Observable<Array<AeronefByYear>> {
        return this.apiService.get(`${this._apiDomain}/aeronefs/allByImatByYear`).pipe(map((data) => data.aeronefs));
    }
}
