import _ from 'lodash'

export default {
  getEligibleCvs: state => {
    return state.cvs
  },
  getEligibleOrderFees: state => {
    return state.orderFees
  },
  getEligibleProducts: state => {
    return state.products
  },
  getEligibleKittings: state => {
    return state.kittings
  },
  getEligiblePromotion: state => {
    return state.promotion
  },
  getSelectedFocItems: state => {
    return state.selectedFocItems
  },
  getSelectedPwpItems: state => {
    return state.selectedPwpItems
  },
  getSelectedFocPwpItems: state => {
    return state.selectedFocPwpItems
  },
  getFocSelectionComplete: state => {
    return state.focSelectionComplete
  },
  getPwpSelectionComplete: state => {
    return state.pwpSelectionComplete
  },
  getSelectedPromotionItems: state => {
    let focItems = _.map(state.selectedFocItems, function(item) {
      return {
        promo_id: item.promo_id,
        option_id: item.option_id,
        set_id: item.set_id,
        product_id: item.product_id,
        operator: item.operator,
        set_key: item.set_key,
        selected_quantity: item.quantity,
        price: item.price,
      }
    })
    let pwpItems = _.map(state.selectedPwpItems, function(item) {
      return {
        promo_id: item.promo_id,
        option_id: item.option_id,
        set_id: item.set_id,
        product_id: item.product_id,
        operator: item.operator,
        set_key: item.set_key,
        selected_quantity: item.quantity,
        price: item.price,
      }
    })
    return _.union(focItems, pwpItems)
  },
  getPwpFocSelectionComplete: state => state.pwpFocSelectionComplete,
}
