import {
  SEARCH_CUSTOMERS_REQUESTED,
  EXTRACT_TAGS_REQUEST,
  UPDATE_PREVIEW_REQUEST,
  SEND_TEST_MESSAGE_REQUESTED,
  CLEAR_CUSTOMER_SEARCH_STATE,
  FETCH_TEST_CUSTOMERS_REQUESTED,
  FETCH_TEST_GROUPS_REQUESTED,
  CREATE_MESSAGE_META_REQUESTED,
  CLEAR_SEARCH_RESULTS,
  GET_PREFILLED_VALUES_REQUESTED,
  CLEAR_PREFILLED_VALUES,
} from './constants';

// Action Creators
export const searchCustomersRequested = (query) => ({
  type: SEARCH_CUSTOMERS_REQUESTED,
  payload: { query },
});

export const extractTagsRequested = (templateSubject, templateContent) => ({
  type: EXTRACT_TAGS_REQUEST,
  payload: { templateSubject, templateContent },
});

export const updatePreviewRequested = (data) => ({
  type: UPDATE_PREVIEW_REQUEST,
  payload: data,
});

export const sendTestMessageRequested = (payload, callback) => ({
  type: SEND_TEST_MESSAGE_REQUESTED,
  payload,
  callback,
});

export const clearCustomerSearchState = () => ({
  type: CLEAR_CUSTOMER_SEARCH_STATE,
});

export const clearSearchResults = () => ({
  type: CLEAR_SEARCH_RESULTS,
});

export const fetchTestCustomersRequested = () => ({
  type: FETCH_TEST_CUSTOMERS_REQUESTED,
});

export const fetchTestGroupsRequested = () => ({
  type: FETCH_TEST_GROUPS_REQUESTED,
});

export const createMessageMetaRequested = (payload, messageMetaConfigId, callback) => ({
  type: CREATE_MESSAGE_META_REQUESTED,
  payload,
  messageMetaConfigId,
  callback,
});

export const getPrefilledValuesRequested = (payload) => ({
  type: GET_PREFILLED_VALUES_REQUESTED,
  payload,
});

export const clearPrefilledValues = () => ({
  type: CLEAR_PREFILLED_VALUES,
});
