import { getCamionAPI } from 'ba-api/camion'; import * as types from './actionTypes' export const setCamiones = (payload) => ({ type: types.LISTA_PEDIDO, payload }); /***************************************/ export function b2fCamiones(x){ const {...other} = x return { id: x.id, codigo: 'A001', placa: x.placa, origen: 'Lima', tipo: x.tipoCamion.nombre, estado: x.estado, capacidad: x.tipoCamion.capacidad, ...other } } /***************************************/ export const getCamiones = () => async dispatch => { try{ const res = await getCamionAPI(); res.data.forEach((x, i) => { res.data[i] = b2fCamiones(x) }); dispatch(setCamiones({res})) return res; }catch(e){ console.log(e) } }