{"size": 494, "ext": "js", "max_stars_repo_path": "client/src/modules/compagny/middlewares/add.js", "max_stars_repo_name": "mmarchois/topflop", "max_stars_repo_stars_event_min_datetime": "2019-10-08T08:30:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-27T17:09:27.000Z", "max_issues_repo_path": "client/src/modules/compagny/middlewares/add.js", "max_issues_repo_name": "mmarchois/topflop", "max_issues_repo_issues_event_min_datetime": "2020-08-19T17:18:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T18:32:03.000Z", "max_forks_repo_path": "client/src/modules/compagny/middlewares/add.js", "max_forks_repo_name": "mmarchois/topflop", "max_forks_repo_forks_event_min_datetime": "2019-10-14T07:10:52.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-21T21:47:27.000Z"}
{"max_stars_count": 9, "max_issues_count": 8, "max_forks_count": 2, "avg_line_length": 29.0588235294, "max_line_length": 76, "alphanum_fraction": 0.6720647773}
import { loading, success, errors } from '../actions/add';
import Compagny from '../models/Compagny';
import errorFormater from '../../../utils/errorFormater';

export const addCompagny = payload => async (dispatch, getState, axios) => {
  dispatch(loading(true));

  try {
    const response = await axios.post('companies', payload);
    dispatch(success(new Compagny(response.data)));
  } catch (e) {
    dispatch(errors(errorFormater(e)));
  } finally {
    dispatch(loading(false));
  }
};
