import { inject, Injectable } from '@angular/core';
import { ShoppingCartService } from '../services';
import {
  AddItemToShoppingCartParams,
  CanAddItemsToShoppingCartParams,
  RemoveShoppingCartItemParams,
  UpdateShoppingCartItemParams,
} from '../schemas';

@Injectable({ providedIn: 'root' })
export class PurchaseOptionsFacade {
  #shoppingCartService = inject(ShoppingCartService);

  get(shoppingCartId: number, abortSignal?: AbortSignal) {
    return this.#shoppingCartService.getShoppingCart(
      shoppingCartId,
      abortSignal,
    );
  }

  canAddItems(params: CanAddItemsToShoppingCartParams) {
    return this.#shoppingCartService.canAddItems(params);
  }

  addItem(params: AddItemToShoppingCartParams) {
    console.log('Adding item to cart', params);
    return this.#shoppingCartService.addItem(params);
  }

  updateItem(params: UpdateShoppingCartItemParams) {
    console.log('Updating item in cart', params);
    return this.#shoppingCartService.updateItem(params);
  }

  removeItem(params: RemoveShoppingCartItemParams) {
    return this.#shoppingCartService.removeItem(params);
  }
}
