diff options
Diffstat (limited to 'front/odiparpack/app/actions/camion.js')
| -rw-r--r-- | front/odiparpack/app/actions/camion.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/front/odiparpack/app/actions/camion.js b/front/odiparpack/app/actions/camion.js new file mode 100644 index 0000000..6fdd2c6 --- /dev/null +++ b/front/odiparpack/app/actions/camion.js @@ -0,0 +1,39 @@ +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) + } +} |
