{"size": 1386, "ext": "js", "max_stars_repo_path": "src/actions/occurrenceReportActions.js", "max_stars_repo_name": "siddharthashok/digital-sky-app", "max_stars_repo_stars_event_min_datetime": "2019-02-19T12:00:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-02T16:53:02.000Z", "max_issues_repo_path": "src/actions/occurrenceReportActions.js", "max_issues_repo_name": "siddharthashok/digital-sky-app", "max_issues_repo_issues_event_min_datetime": "2018-12-01T07:05:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T10:41:47.000Z", "max_forks_repo_path": "src/actions/occurrenceReportActions.js", "max_forks_repo_name": "siddharthashok/digital-sky-app", "max_forks_repo_forks_event_min_datetime": "2018-07-11T09:41:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-16T15:06:13.000Z"}
{"max_stars_count": 2, "max_issues_count": 14, "max_forks_count": 11, "avg_line_length": 28.2857142857, "max_line_length": 79, "alphanum_fraction": 0.7142857143}
import { droneService } from "../services/droneTypeService";

export const SAVE_OCCURRENCE_REPORT_SUCCESS = "SAVE_OCCURRENCE_REPORT_SUCCESS";
export const SAVE_OCCURRENCE_REPORT_FAILURE = "SAVE_OCCURRENCE_REPORT_FAILURE";
export const LOAD_OCCURRENCE_REPORTS_SUCCESS =
  "LOAD_OCCURRENCE_REPORTS_SUCCESS";
export const LOAD_OCCURRENCE_REPORTS_FAILURE =
  "LOAD_OCCURRENCE_REPORTS_FAILURE";

export const loadOccurrenceReportsAction = drone_id => {
  return dispatch => {
    droneService.loadOccurrenceReports(drone_id).then(
      occurrenceReports => {
        dispatch(success(occurrenceReports));
      },
      errors => {
        dispatch(failure(errors));
      }
    );
  };

  function success(occurrenceReports) {
    return { type: LOAD_OCCURRENCE_REPORTS_SUCCESS, occurrenceReports };
  }
  function failure(errors) {
    return { type: LOAD_OCCURRENCE_REPORTS_FAILURE, errors };
  }
};

export const saveOccurrenceReportAction = occurrenceReport => {
  return dispatch => {
    droneService.saveOccurrenceReport(occurrenceReport).then(
      savedReport => {
        dispatch(success(savedReport));
      },
      errors => {
        dispatch(failure(errors));
      }
    );
  };

  function success(report) {
    return { type: SAVE_OCCURRENCE_REPORT_SUCCESS, report };
  }
  function failure(errors) {
    return { type: SAVE_OCCURRENCE_REPORT_FAILURE, errors };
  }
};
