import { ESHOP_CW_INFO } from '@/store/utils/apiUrls'
import { get } from '@/store/utils/api'
import {
  ESHOP_SET_CW_INFO,
  PROCESSING_FINISHED,
  PROCESSING_STARTED,
  ESHOP_SET_CART_SALES_CW_ID,
} from '@/store/utils/types'

export const loadCwInfo = ({ commit }) => {
  commit(PROCESSING_STARTED, 'cwInfo', { root: true })
  return get(ESHOP_CW_INFO).then(response => {
    commit(ESHOP_SET_CW_INFO, response.data)
    commit(PROCESSING_FINISHED, 'cwInfo', { root: true })
  })
}

export const setCartSalesCwId = ({ commit }, cwId) => {
  commit(ESHOP_SET_CART_SALES_CW_ID, cwId)
}
