import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment';

@Injectable({ providedIn: 'root' })
export class PurchasesSettingsService {
  private http = inject(HttpClient);
  private apiUrl = `${environment.apiUrl}/purchases/settings`;

  getSettings(): Observable<{ data: any[] }> {
    return this.http.get<{ data: any[] }>(this.apiUrl);
  }

  updateSettings(data: Record<string, any>): Observable<{ data: any[] }> {
    return this.http.put<{ data: any[] }>(this.apiUrl, data);
  }
}
