import { INAPP } from "../CreativesContainer/constants";
import {
  INAPP_TEMPLATE_CREATE_REQUEST,
  CLEAR_CREATE_RESPONSE_REQUEST,
  GET_INAPP_TEMPLATE_DETAILS_REQUEST,
  RESET_EDIT_TEMPLATE,
  UPLOAD_INAPP_ASSET_REQUEST,
  CLEAR_INAPP_ASSET,
  INAPP_EDIT_TEMPLATE_REQUEST,
  GET_BEE_POPUP_BUILDER_TOKEN_REQUEST,
} from "./constants";

export function createInAppTemplate(payload, callback) {
  return {
    type: INAPP_TEMPLATE_CREATE_REQUEST,
    payload,
    callback,
  };
}
export function clearCreateResponse() {
  return {
    type: CLEAR_CREATE_RESPONSE_REQUEST,
  };
}
// FOR EDIT
export function getTemplateDetails(id, callback) {
  return {
    type: GET_INAPP_TEMPLATE_DETAILS_REQUEST,
    id,
    channel: INAPP,
    callback,
  };
}

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

export function resetEditTemplate() {
  return {
    type: RESET_EDIT_TEMPLATE,
  };
}

export const uploadInAppAsset = (
  file,
  assetType,
  fileParams,
  templateType,
) => ({
  type: UPLOAD_INAPP_ASSET_REQUEST,
  file,
  assetType,
  fileParams,
  templateType,
});

export const clearInAppAsset = (templateType) => ({
  type: CLEAR_INAPP_ASSET,
  templateType,
});

export function getBeePopupBuilderToken() {
  return {
    type: GET_BEE_POPUP_BUILDER_TOKEN_REQUEST,
  };
}
