blob: 6fdd2c60e642d6dc064c7be53456397640af95db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)
}
}
|