import { Action } from '@ngrx/store';
import { Customer } from 'src/app/models/customer.model';
import { ResultApi } from 'src/app/models/result-api.model';
import { OrderDeliveryTax } from '../models/order-delivery-tax.model';
import { OrderDiscount } from '../models/order-discount.model';
import { ShoppingItem } from '../models/shopping-item';
import { Shopping } from '../models/shopping.model';

export enum ShoppingActionTypes {
  LOAD_SHOPPING = '[SHOPPING] Load Shopping',
  LOAD_SHOPPING_SUCCESS = '[SHOPPING] Load Shopping Success',
  LOAD_SHOPPING_FAILURE = '[SHOPPING] Load Shopping Failure',
  UPDATE_SHOPPING = '[SHOPPING] Update Shopping',
  UPDATE_SHOPPING_SUCCESS = '[SHOPPING] Update Shopping Success',
  UPDATE_SHOPPING_FAILURE = '[SHOPPING] Update Shopping Failure',
  UPDATE_DELIVERY_TAX = '[SHOPPING] Update Delivery Tax',
  UPDATE_DELIVERY_TAX_SUCCESS = '[SHOPPING] Update Delivery Tax Success',
  UPDATE_DELIVERY_TAX_FAILURE = '[SHOPPING] Update Delivery Tax Failure',
  LOAD_SHOPPING_ITEMS = '[SHOPPING] Load Shopping Items',
  LOAD_SHOPPING_ITEMS_SUCCESS = '[SHOPPING] Load Shopping Items Success',
  LOAD_SHOPPING_ITEMS_FAILURE = '[SHOPPING] Load Shopping Items Failure',
  ADD_ITEM = '[SHOPPING] Add Item',
  ADD_ITEM_SUCCESS = '[SHOPPING] Add Item Success',
  ADD_ITEM_FAILURE = '[SHOPPING] Add Item Failure',
  UPDATE_PRICE_ITEM = '[SHOPPING] Update Price Item',
  UPDATE_PRICE_ITEM_SUCCESS = '[SHOPPING] Update Price Item Success',
  UPDATE_PRICE_ITEM_FAILURE = '[SHOPPING] Update Price Item Failure',
  UPDATE_QUANTITY_ITEM = '[SHOPPING] Update quantity Item',
  UPDATE_QUANTITY_ITEM_SUCCESS = '[SHOPPING] Update quantity Item Success',
  UPDATE_QUANTITY_ITEM_FAILURE = '[SHOPPING] Update quantity Item Failure',
  DELETE_ITEM = '[SHOPPING] Delete Item',
  DELETE_ITEM_SUCCESS = '[SHOPPING] Delete Item Success',
  DELETE_ITEM_FAILURE = '[SHOPPING] Delete Item Failure',
  APPLY_DISCOUNT_ORDER = '[SHOPPING] Apply discount Order',
  APPLY_DISCOUNT_ORDER_SUCCESS = '[SHOPPING] Apply discount Order Success',
  APPLY_DISCOUNT_ORDER_FAILURE = '[SHOPPING] Apply discount Order Failure',
  SELECT_CUSTOMER = '[CUSTOMER] Select Customer',
  SELECT_CUSTOMER_SUCCESS = '[CUSTOMER] Select Customer Success',
  SELECT_CUSTOMER_FAILURE = '[CUSTOMER] Select Customer Failure',

}


export class LoadShoppingItemsAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING_ITEMS;

  constructor(public payload: string) { }
}
export class LoadShoppingItemsSuccessAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING_ITEMS_SUCCESS;

  constructor(public payload: ShoppingItem[]) {}

}
export class LoadShoppingItemsFailureAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING_ITEMS_FAILURE;
  constructor(public payload: Error) {}
}

export class AddItemAction implements Action {
  readonly type = ShoppingActionTypes.ADD_ITEM;

  constructor(public payload: ShoppingItem) { }
}
export class AddItemSuccessAction implements Action {
  readonly type = ShoppingActionTypes.ADD_ITEM_SUCCESS;

  constructor(public payload: ShoppingItem) { }
}
export class AddItemFailureAction implements Action {
  readonly type = ShoppingActionTypes.ADD_ITEM_FAILURE;

  constructor(public payload: Error) { }
}

export class UpdatePriceItemAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_PRICE_ITEM;

  constructor(public payload: ShoppingItem) { }
}
export class UpdatePriceItemSuccessAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_PRICE_ITEM_SUCCESS;

  constructor(public payload: ShoppingItem) { }
}
export class UpdatePriceItemFailureAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_PRICE_ITEM_FAILURE;

  constructor(public payload: Error) { }
}

export class LoadShoppingAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING;

  constructor(public payload: string) { }
}

export class LoadShoppingSuccessAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING_SUCCESS;

  constructor(public payload: Shopping) { }
}

export class LoadShoppingFailureAction implements Action {
  readonly type = ShoppingActionTypes.LOAD_SHOPPING_FAILURE;

  constructor(public payload: Error) { }
}

export class UpdateShoppingAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_SHOPPING;

  constructor(public payload: Shopping) { }
}
export class UpdateShoppingSuccessAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_SHOPPING_SUCCESS;

  constructor(public payload: Shopping) { }
}
export class UpdateShoppingFailureAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_SHOPPING_FAILURE;

  constructor(public payload: Error) { }
}

export class UpdateDeliveryTaxAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_DELIVERY_TAX;

  constructor(public payload: OrderDeliveryTax) { }
}

export class UpdateDeliveryTaxSuccessAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_DELIVERY_TAX_SUCCESS;

  constructor(public payload: Shopping) { }
}

export class UpdateDeliveryTaxFailureAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_DELIVERY_TAX_FAILURE;

  constructor(public payload: Error) { }
}


export class UpdateQuantityItemAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_QUANTITY_ITEM;

  constructor(public payload: ShoppingItem) { }
}
export class UpdateQuantityItemSuccessAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_QUANTITY_ITEM_SUCCESS;

  constructor(public payload: ShoppingItem) { }
}
export class UpdateQuantityItemFailureAction implements Action {
  readonly type = ShoppingActionTypes.UPDATE_QUANTITY_ITEM_FAILURE;

  constructor(public payload: Error) { }
}

export class DeleteItemAction implements Action {
  readonly type = ShoppingActionTypes.DELETE_ITEM;

  constructor(public payload: string) { }
}

export class DeleteItemSuccessAction implements Action {
  readonly type = ShoppingActionTypes.DELETE_ITEM_SUCCESS;

  constructor(public payload: ResultApi) { }
}
export class DeleteItemFailureAction implements Action {
  readonly type = ShoppingActionTypes.DELETE_ITEM_FAILURE;

  constructor(public payload: Error) { }
}

export class SelectCustomerAction implements Action {
  readonly type = ShoppingActionTypes.SELECT_CUSTOMER;

  constructor(public payload: Customer) { }
}
export class SelectCustomerSuccessAction implements Action {
  readonly type = ShoppingActionTypes.SELECT_CUSTOMER_SUCCESS;

  constructor(public payload: Customer) {}

}
export class SelectCustomerFailureAction implements Action {
  readonly type = ShoppingActionTypes.SELECT_CUSTOMER_FAILURE;
  constructor(public payload: Error) {}
}

export class ApplyDiscountOrderAction implements Action {
  readonly type = ShoppingActionTypes.APPLY_DISCOUNT_ORDER;

  constructor(public payload: OrderDiscount) { }
}
export class ApplyDiscountOrderSuccessAction implements Action {
  readonly type = ShoppingActionTypes.APPLY_DISCOUNT_ORDER_SUCCESS;

  constructor(public payload: ShoppingItem[]) {}

}
export class ApplyDiscountOrderFailureAction implements Action {
  readonly type = ShoppingActionTypes.APPLY_DISCOUNT_ORDER_FAILURE;
  constructor(public payload: Error) {}
}


export type ShoppingAction = AddItemAction |
  AddItemSuccessAction |
  AddItemFailureAction |
  UpdatePriceItemAction |
  UpdatePriceItemSuccessAction |
  UpdatePriceItemFailureAction |
  UpdateQuantityItemAction |
  UpdateQuantityItemSuccessAction |
  UpdateQuantityItemFailureAction |
  DeleteItemAction |
  DeleteItemSuccessAction |
  DeleteItemFailureAction |
  LoadShoppingItemsAction |
  LoadShoppingItemsFailureAction |
  LoadShoppingItemsSuccessAction |
  LoadShoppingAction |
  LoadShoppingFailureAction |
  LoadShoppingSuccessAction |
  UpdateShoppingAction |
  UpdateShoppingFailureAction |
  UpdateShoppingSuccessAction |
  UpdateDeliveryTaxAction |
  UpdateDeliveryTaxFailureAction |
  UpdateDeliveryTaxSuccessAction |
  ApplyDiscountOrderAction |
  ApplyDiscountOrderSuccessAction |
  ApplyDiscountOrderFailureAction;


