{"size": 647, "ext": "js", "max_stars_repo_path": "front_petrolinda/src/reducers/Abastecimentos/index.js", "max_stars_repo_name": "tulioaoki/petrolinda_frontend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "front_petrolinda/src/reducers/Abastecimentos/index.js", "max_issues_repo_name": "tulioaoki/petrolinda_frontend", "max_issues_repo_issues_event_min_datetime": "2020-09-07T16:48:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T20:06:35.000Z", "max_forks_repo_path": "front_petrolinda/src/reducers/Abastecimentos/index.js", "max_forks_repo_name": "tulioaoki/petrolinda_frontend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 24.8846153846, "max_line_length": 91, "alphanum_fraction": 0.6043276662}
import { GET_ABASTECIMENTOS, REGISTER_ABASTECIMENTOS } from '../../actions/Abastecimentos';

export default function REDUCER_ABASTECIMENTOS(state = { abastecimentos: [] }, action) {
  let arr;
  const newAbastecimentos = state.abastecimentos;
  switch (action.type) {
    case GET_ABASTECIMENTOS:
      if (!action.payload) {
        arr = [];
      } else {
        arr = action.payload;
      }
      return {
        ...state,
        abastecimentos: arr,
      };
    case REGISTER_ABASTECIMENTOS:
      return {
        ...state,
        abastecimentos: [action.payload, ...newAbastecimentos],
      };
    default:
      return state;
  }
}
