import { Injectable } from '@angular/core';
import { map, catchError } from 'rxjs/operators';
import { FeedMapping } from 'apps/sales/src/app/core/mappings/feed.mapping';
import { Observable } from 'rxjs';
import { FeedCard } from '../models/feed-card.model';
import { ListResponseArgsOfFeedDTO } from '@swagger/isa';
import { HttpClient } from '@angular/common/http';
import { InfoService } from '@swagger/isa';

@Injectable({
  providedIn: 'root',
})
export class DashboardFeedService {
  constructor(private infoService: InfoService, private feedMapping: FeedMapping, private http: HttpClient) {}

  info(): Observable<FeedCard[]> {
    return this.infoService
      .InfoInfo({ take: null, skip: null })
      .pipe(map((feed: ListResponseArgsOfFeedDTO) => feed.result.map((t) => this.feedMapping.fromFeedDTO(t))));
  }
}
