<commit_before>import store from './STORE.jsx';
// ACTIONS for APP component

// TYPES-----------------------
// sync
export const SET_FILTER = 'SET_FILTER';
export const SELECT_TOPIC = 'SELECT_TOPIC';
export const UPDATE_MAP_BOUNDS = 'UPDATE_MAP_BOUNDS';
// async
export const CREATE_PLURB = 'CREATE_PLURB';
export const GET_PLURBS = 'GET_PLURBS';
export const LOAD_PLURBS = 'LOAD_PLURBS';
export const FETCHING = 'FETCHING';

// CREATORS--------------------
// sync
export function selectTopic(currentTopic) {
  return { type: SELECT_TOPIC, currentTopic }
}

export function setFilter(filter) {
  return { type: SET_FILTER, filter }
}

// async
export function updateMapBounds(mapBounds) {
  return { type: UPDATE_MAP_BOUNDS, mapBounds }
}

export function createPlurb(data) {
  // data is plurb object from Maker
  fetch('/api/plurb', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
  }).then((body) => {
    store.dispatch(getPlurbs());
  }).catch((error) => {
    console.err(error);
  });

  return { type: CREATE_PLURB, fetching: true }   
}

// ASYNC ACTIONS
export function getPlurbs(options) {
  // update getPlurbs to handle text filtering on CLIENT-SIDE
  // all plurbs are stored on client on first render, then filter on client-side
  // after initial load, only updates come from server
  // filter param 'PUBLIC', 'PRIVATE', {text}, {location}, etc. for individual plurbs
  fetch('/api/plurb', {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      },
    }).then((plurbs) => plurbs.text())
      .then((plurbs) => {
      store.dispatch(loadPlurbs(plurbs));
    }).catch((error) => {<commit_msg>(feat) Include body param on request for plurbs<commit_after>import store from './STORE.jsx';
// ACTIONS for APP component

// TYPES-----------------------
// sync
export const SET_FILTER = 'SET_FILTER';
export const SELECT_TOPIC = 'SELECT_TOPIC';
export const UPDATE_MAP_BOUNDS = 'UPDATE_MAP_BOUNDS';
// async
export const CREATE_PLURB = 'CREATE_PLURB';
export const GET_PLURBS = 'GET_PLURBS';
export const LOAD_PLURBS = 'LOAD_PLURBS';
export const FETCHING = 'FETCHING';

// CREATORS--------------------
// sync
export function selectTopic(currentTopic) {
  return { type: SELECT_TOPIC, currentTopic }
}

export function setFilter(filter) {
  return { type: SET_FILTER, filter }
}

// async
export function updateMapBounds(mapBounds) {
  return { type: UPDATE_MAP_BOUNDS, mapBounds }
}

export function createPlurb(data) {
  // data is plurb object from Maker
  fetch('/api/plurb', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
  }).then((body) => {
    store.dispatch(getPlurbs());
  }).catch((error) => {
    console.err(error);
  });

  return { type: CREATE_PLURB, fetching: true }   
}

// ASYNC ACTIONS
export function getPlurbs(options) {
  // update getPlurbs to handle text filtering on CLIENT-SIDE
  // all plurbs are stored on client on first render, then filter on client-side
  // after initial load, only updates come from server
  // filter param 'PUBLIC', 'PRIVATE', {text}, {location}, etc. for individual plurbs
  fetch('/api/plurb', {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      },
      body: options
    }).then((plurbs) => plurbs.text())
      .then((plurbs) => {
      store.dispatch(loadPlurbs(plurbs));
    }).catch((error) => {
{'fraction_non_alphanumeric': 0.1597909790979098, 'fraction_numerical': 0.0, 'mean_word_length': 3.219257540603248, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4785751', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1142, 'n_words': 305}