/*
 *
 * Create actions
 *
 */

import * as types from './constants';

export function createTemplate(template, callback) {
  return {
    type: types.CREATE_TEMPLATE_REQUEST,
    template,
    callback,
  };
}

export function clearCreateResponse() {
  return {
    type: types.CLEAR_CREATE_RESPONSE_REQUEST,
  };
}

export function defaultAction() {
  return {
    type: types.DEFAULT_ACTION,
  };
}

export function uploadAsset(file, assetType, fileParams, index = 0, mobilePushParams = {}) {
  return {
    type: types.UPLOAD_ASSET_REQUEST,
    file,
    assetType,
    fileParams,
    index,
    mobilePushParams,
  };
}

export function getIosCtas(licenseCode) {
  return {
    type: types.GET_IOS_CTAS, licenseCode,
  };
}

export function clearAsset(index = undefined) {
  return {
    type: types.CLEAR_ASSET,
    index,
  };
}

export function resetStore() {
  return {
    type: types.RESET_STORE,
  };
}

export function getTemplateDetails(id) {
  return {
    type: types.GET_TEMPLATE_DETAILS_REQUEST, id,
  };
}

export function editTemplate(template, callback) {
  return {
    type: types.EDIT_TEMPLATE_REQUEST, template, callback,
  };
}

export function clearEditResponse() {
  return {
    type: types.CLEAR_EDIT_RESPONSE_REQUEST,
  };
}

export function clearData() {
  return {
    type: types.CLEAR_DATA,
  };
}

export function getWeCrmAccounts(source) {
  return {
    type: types.GET_WECRM_ACCOUNTS_REQUEST, source,
  };
}

export function setWeChatAccount(weChatAccount) {
  return {
    type: types.SET_WECHAT_ACCOUNT,
    weChatAccount,
  };
}

export function getMobilepushTemplatesList(channel, queryParams) {
  return {
    type: types.GET_MOBILEPUSH_TEMPLATES_LIST_REQUEST,
    channel,
    queryParams,
  };
}

export function setSelectedTemplate(templateData) {
  return {
    type: types.SET_SELECTED_TEMPLATE,
    data: templateData,
  };
}

export function setTemplateDetails(templateDetails) {
  return {
    type: types.GET_TEMPLATE_DETAILS_SUCCESS,
    data: templateDetails,
  };
}
