import { AvailabilityDTO } from '@swagger/cat';
import { CartEntry } from '../../models/cart-entry.model';
import { AddressDTO } from '@swagger/checkout';
export const SET_CART_ENTRY = '[CARTENTRY] Set cart entry';
export const UPDATE_CART_ENTRY_QUANTITY = '[CARTENTRY] update cart item quantity';
export const DELETE_CART_ENTRY = '[CARTENTRY] Delete cart entry';
export const RELOAD_STATE = '[CARTENTRY] Reload data from API';
export const UPDATE_CART_ENTRY_ORDER_TYPE = '[CARTENTRY] Update cart item type';
export const SET_SHIPPING_ADDRESS_FOR_DOWNLOAD_ITEMS = '[CARTENTRY] Set destination for download items';

export class SetCartEntry {
  static readonly type = SET_CART_ENTRY;

  constructor(
    public quantity: number,
    public deliveryType: string,
    public bookId: number,
    public availability: AvailabilityDTO,
    public branch: number,
    public promoPoints: number
  ) {}
}

export class UpdateCartEntryQuantity {
  static readonly type = UPDATE_CART_ENTRY_QUANTITY;

  constructor(
    public quantity: number,
    public cartEntryId: number,
    public availability: AvailabilityDTO,
    public availabilityMsg: string = ''
  ) {}
}

export class DeleteCartEntry {
  static readonly type = DELETE_CART_ENTRY;

  constructor(public cartEntryId: number, public hardDelete: boolean = false) {}
}

export class ReloadCartEntryData {
  static readonly type = RELOAD_STATE;

  constructor(public cartEntries: { [key: number]: CartEntry }) {}
}

export class UpdateCartEntryType {
  static readonly type = UPDATE_CART_ENTRY_ORDER_TYPE;

  constructor(
    public deliveryType: string,
    public bookId: number,
    public availability: AvailabilityDTO,
    public branch: number,
    public oldDeliveryType: string,
    public oldBranch: number
  ) {}
}

export class SetShippingForDownloadCart {
  static readonly type = SET_SHIPPING_ADDRESS_FOR_DOWNLOAD_ITEMS;

  constructor(public address: AddressDTO, public cartEntriesIds: number[]) {}
}
