import {
  RCS,
  UPLOAD_RCS_ASSET_REQUEST,
  CLEAR_RCS_ASSET,
  CREATE_RCS_TEMPLATE_REQUEST,
  CLEAR_CREATE_RESPONSE_REQUEST,
  GET_RCS_TEMPLATE_DETAILS_REQUEST,
  CLEAR_EDIT_RESPONSE_REQUEST,
  EDIT_RCS_TEMPLATE_REQUEST,
  CLEAR_RCS_MEDIA_ASSET,
} from './constants';

export const uploadRcsAsset = (file, assetType, fileParams, index = 0) => ({
  type: UPLOAD_RCS_ASSET_REQUEST,
  file,
  assetType,
  fileParams,
  index,
});

export const clearRcsMediaAsset = (index) => ({
  type: CLEAR_RCS_MEDIA_ASSET,
  index,
});

export const clearCreateResponse = () => ({
  type: CLEAR_CREATE_RESPONSE_REQUEST,
});

export const createRcsTemplate = (template, callback) => ({
  type: CREATE_RCS_TEMPLATE_REQUEST,
  template,
  callback,
});

// FOR EDIT
export function getTemplateDetails(id, callback) {
  return {
    type: GET_RCS_TEMPLATE_DETAILS_REQUEST,
    id,
    channel: RCS,
    callback,
  };
}

export function editTemplate(template, callback) {
  return {
    type: EDIT_RCS_TEMPLATE_REQUEST,
    template,
    callback,
  };
}

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

export const SET_RCS_ACCOUNT = "SET_RCS_ACCOUNT";
