import {
  TEMPLATE_CREATE_REQUEST,
  CLEAR_CREATE_RESPONSE_REQUEST,
  GET_TEMPLATE_DETAILS_REQUEST,
  RESET_EDIT_TEMPLATE,
  WHATSAPP,
  UPLOAD_WHATSAPP_ASSET_REQUEST,
  CLEAR_WHATSAPP_ASSET,
  URL_META_TAGS_REQUEST,
  URL_META_TAGS_RESET,
} from './constants';

export function createWhatsappTemplate(payload, callback, gupshupMediaFile) {
  return {
    type: TEMPLATE_CREATE_REQUEST,
    payload,
    callback,
    gupshupMediaFile,
  };
}
export function clearCreateResponse() {
  return {
    type: CLEAR_CREATE_RESPONSE_REQUEST,
  };
}
// FOR EDIT
export function getTemplateDetails(id, callback) {
  return {
    type: GET_TEMPLATE_DETAILS_REQUEST,
    id,
    channel: WHATSAPP,
    callback,
  };
}
export function resetEditTemplate() {
  return {
    type: RESET_EDIT_TEMPLATE,
  };
}

export const uploadWhatsappAsset = (
  file,
  assetType,
  fileParams,
  templateType,
  whatsappParams,
) => ({
  type: UPLOAD_WHATSAPP_ASSET_REQUEST,
  file,
  assetType,
  fileParams,
  templateType,
  whatsappParams,
});

export const clearWhatsappAsset = (templateType) => ({
  type: CLEAR_WHATSAPP_ASSET,
  templateType,
});

export function getMetaTags({previewUrl, callBack}) {
  return {
    type: URL_META_TAGS_REQUEST,
    previewUrl,
    callBack,
  };
}

export function resetMetaTags() {
  return {
    type: URL_META_TAGS_RESET,
  };
}
