import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { ProductCardConfig, CategoryCardConfig } from '../../../shared/models/ui';
import { BackofficeDataProvider } from './backoffice-data-provider.interface';

@Injectable({ providedIn: 'root' })
export class ApiBackofficeDataProvider implements BackofficeDataProvider {
  constructor(private readonly http: HttpClient) {}

  loadProducts(): Observable<ProductCardConfig[]> {
    return this.http.get<ProductCardConfig[]>('/api/backoffice/products');
  }

  loadCategories(): Observable<CategoryCardConfig[]> {
    return this.http.get<CategoryCardConfig[]>('/api/backoffice/categories');
  }
}
