<commit_before>import axios from 'axios'
import { toastr } from 'react-redux-toastr'
import { reset as resetForm, initialize } from 'redux-form'
import { showTabs, selectTab } from '../common/tab/tabActions'

const BASE_URL = 'http://localhost:3003/api'
const INITIAL_VALUES = {}

export function getList() {
  const request = axios.get(`${BASE_URL}/billingCycles`)
  return {
    type: 'BILLING_CYCLES_FETCHED',
    payload: request
  }
}

export function create(values) {
  return dispatch => {
    axios.post(`${BASE_URL}/billingCycles`, values)
        .then(resp => {
          toastr.success('Sucesso', 'Operação realizada com sucesso')
          dispatch([
            resetForm('billingCycleForm'),
            getList(),
            selectTab('tabList'),
            showTabs('tabList', 'tabC')
          ])
        })
        .catch(e => {
          e.response.data.errors.forEach(error => toastr.error('Erro', error))
        })
  }<commit_msg>tornando dinamica a função create para utilizar no put<commit_after>import axios from 'axios'
import { toastr } from 'react-redux-toastr'
import { reset as resetForm, initialize } from 'redux-form'
import { showTabs, selectTab } from '../common/tab/tabActions'

const BASE_URL = 'http://localhost:3003/api'
const INITIAL_VALUES = {}

export function getList() {
  const request = axios.get(`${BASE_URL}/billingCycles`)
  return {
    type: 'BILLING_CYCLES_FETCHED',
    payload: request
  }
}

export function create(values) {
  return submit(values, 'post')
}

export function update(values) {
  return submit(values, 'put')
}

function submit(values, method) {
  return dispatch => {
    const id = value._id ? values._id : ''
    axios[method](`${BASE_URL}/billingCycles/${id}`, values)
    .then(resp => {
      toastr.success('Sucesso', 'Operação realizada com sucesso')
      dispatch([
        resetForm('billingCycleForm'),
        getList(),
        selectTab('tabList'),
        showTabs('tabList', 'tabC')
      ])
    })
    .catch(e => {
      e.response.data.errors.forEach(error => toastr.error('Erro', error))
    })
  }
{'fraction_non_alphanumeric': 0.1449067431850789, 'fraction_numerical': 0.003825920612147298, 'mean_word_length': 3.1756487025948106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7550900', 'n_tokens_mistral': 692, 'n_tokens_neox': 685, 'n_words': 142}