<commit_before>import fetch from 'isomorphic-fetch';
import {
  FETCH_ITEMS,
  FETCH_ACCOUNT_DETAILS,
  UPDATE_LOCALE,
} from '../constants/actionTypes';

export function setState(state) {
  return {
    type: 'SET_STATE',
    state,
  };
}

export function filterEntries(input) {
  return {
    meta: { remote: true },
    type: 'FILTER_ENTRIES',
    input,
  };
}

export function fetchItems() {
  return {
    type: FETCH_ITEMS,
    payload: {
      promise: fetch('/api/items', { credentials: 'include' })
                .then(response => (response.ok ? response : Promise.reject(response)))
                .then(response => response.json()),
    },
  };
}

export function fetchAccountDetails() {
  return {
    type: FETCH_ACCOUNT_DETAILS,
    payload: {
      promise: fetch('/account', { credentials: 'include' })
                .then(response => (response.ok ? response : Promise.reject(response)))
                .then(response => response.json()),
    },
  };
}

export function updateLocale(payload) {<commit_msg>WD-64 Added comment to update `fetchAccountDetails` action creator later<commit_after>import fetch from 'isomorphic-fetch';
import {
  FETCH_ITEMS,
  FETCH_ACCOUNT_DETAILS,
  UPDATE_LOCALE,
} from '../constants/actionTypes';

export function setState(state) {
  return {
    type: 'SET_STATE',
    state,
  };
}

export function filterEntries(input) {
  return {
    meta: { remote: true },
    type: 'FILTER_ENTRIES',
    input,
  };
}

export function fetchItems() {
  return {
    type: FETCH_ITEMS,
    payload: {
      promise: fetch('/api/items', { credentials: 'include' })
                .then(response => (response.ok ? response : Promise.reject(response)))
                .then(response => response.json()),
    },
  };
}

// TODO: fix: on refresh -> anon user -> raises an exception
// needs to be caught
// however, then breaks logging functionality
export function fetchAccountDetails() {
  return {
    type: FETCH_ACCOUNT_DETAILS,
    payload: {
      promise: fetch('/account', { credentials: 'include' })
                .then(response => (response.ok ? response : Promise.reject(response)))
                .then(response => response.json()),
    },
  };
}

export function updateLocale(payload) {
{'fraction_non_alphanumeric': 0.1371326803205699, 'fraction_numerical': 0.0008904719501335708, 'mean_word_length': 2.9352014010507883, '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': '2628991', 'n_tokens_mistral': 691, 'n_tokens_neox': 674, 'n_words': 154}