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 MockBackofficeDataProvider implements BackofficeDataProvider {
  private readonly productsUrl = '/assets/mock/backoffice/products/list.json';
  private readonly categoriesUrl = '/assets/mock/backoffice/categories/list.json';

  constructor(private readonly http: HttpClient) {}

  loadProducts(): Observable<ProductCardConfig[]> {
    return this.http.get<ProductCardConfig[]>(this.productsUrl);
  }

  loadCategories(): Observable<CategoryCardConfig[]> {
    return this.http.get<CategoryCardConfig[]>(this.categoriesUrl);
  }
}
