diff options
Diffstat (limited to 'front/odiparpack/app/actions')
| -rw-r--r-- | front/odiparpack/app/actions/actionTypes.js | 4 | ||||
| -rw-r--r-- | front/odiparpack/app/actions/camion.js | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/front/odiparpack/app/actions/actionTypes.js b/front/odiparpack/app/actions/actionTypes.js index 8fd305f..11884c0 100644 --- a/front/odiparpack/app/actions/actionTypes.js +++ b/front/odiparpack/app/actions/actionTypes.js @@ -90,4 +90,6 @@ export const OPEN_MESSAGE = 'OPEN_MESSAGE'; //Odi Pedido export const LISTA_PEDIDO = 'LISTA_PEDIDO'; //Odi Almacen -export const LISTA_ALMACEN = 'LISTA_ALMACEN';
\ No newline at end of file +export const LISTA_ALMACEN = 'LISTA_ALMACEN'; +//Odi Camion +export const LISTA_CAMION = 'LISTA_CAMION'; 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) + } +} |
