{"size": 1304, "ext": "js", "max_stars_repo_path": "src/redux/actions/index.js", "max_stars_repo_name": "berkaygure/report-designer", "max_stars_repo_stars_event_min_datetime": "2019-03-04T15:01:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T19:01:56.000Z", "max_issues_repo_path": "src/redux/actions/index.js", "max_issues_repo_name": "berkaygure/fatura-tasarimi", "max_issues_repo_issues_event_min_datetime": "2019-05-31T13:01:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T04:59:08.000Z", "max_forks_repo_path": "src/redux/actions/index.js", "max_forks_repo_name": "berkaygure/fatura-tasarimi", "max_forks_repo_forks_event_min_datetime": "2019-02-22T14:08:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-17T14:12:20.000Z"}
{"max_stars_count": 48, "max_issues_count": 5, "max_forks_count": 22, "avg_line_length": 17.8630136986, "max_line_length": 54, "alphanum_fraction": 0.6679447853}
import axios from 'axios';
import {
  INITIALIZE_APP,
  ADD_TO_SCENE,
  MAKE_ELEMENT_ACTIVE,
  CHANGE_PROPERTIES,
  DROP_ELEMENT
} from './types';

/**
 * Apply loaded settings to application
 *
 * @param {object} settings
 */
export const initializeApp = settings => ({
  type: INITIALIZE_APP,
  payload: settings
});

/**
 * Loads settings from a JSON
 */
export const loadSettings = () => async dispatch => {
  const res = await axios.get('./settings.json');
  const data = await res.data;
  dispatch(initializeApp(data));
};

/**
 * Adds dropped element to scene
 *
 * @param {object} object
 */
export const addToScene = (id, object) => ({
  type: ADD_TO_SCENE,
  payload: {
    id,
    object
  }
});

/**
 * Makes active to clicked element and disable others.
 *
 * @param {string} elementId
 */
export const makeElementActive = elementId => ({
  type: MAKE_ELEMENT_ACTIVE,
  payload: elementId
});

/**
 * Updates selected elements location.
 *
 * @param {string} elementId
 * @param {object} props
 */
export const changeProperties = location => ({
  type: CHANGE_PROPERTIES,
  payload: location
});

/**
 * Updates selected elements location.
 *
 * @param {string} elementId
 * @param {object} props
 */
export const dropElement = elementId => ({
  type: DROP_ELEMENT,
  payload: elementId
});
