diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js
index b11881f..d1fd553 100644
--- a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js
+++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js
@@ -19,7 +19,8 @@ import {
} from '@material-ui/core';
import { anchorTable, dataApi } from './sampleData';
import FormPedido from './FormPedido';
-
+//actions
+import { setPedidos, getPedidos } from '../../../../actions/pedido';
const branch = 'crudPedido';
@@ -40,7 +41,25 @@ const styles = ({
});
class CrudPedido extends Component {
+ constructor (props) {
+ super(props)
+ this.state = {
+ dataReal: []
+ };
+
+ this.props.dispatch(getPedidos())
+ .then( res => {
+ console.log("aqui en el then ps", res)
+ this.setState({
+ dataReal: res
+ })
+ })
+ console.log("aqui en el then ps 2", this.props.pedidosLista)
+
+ }
+
render() {
+ console.log("render ps")
const {
classes,
fetchData,
@@ -56,6 +75,11 @@ class CrudPedido extends Component {
messageNotif,
title,
} = this.props;
+
+ const {dataReal} = this.state;
+ //console.log("render ps DATA", dataReal)
+ //console.log("original", dataApi)
+
return (
closeNotif(branch)} message={messageNotif} />
@@ -63,7 +87,7 @@ class CrudPedido extends Component {
({
dataTable: state.getIn([branch, 'dataTable']),
openForm: state.getIn([branch, 'showFrm']),
messageNotif: state.getIn([branch, 'notifMsg']),
+ pedidosLista : state.getIn(['pedido','pedidos']),
});
const mapDispatchToProps = dispatch => ({
@@ -122,6 +147,7 @@ const mapDispatchToProps = dispatch => ({
removeRow: bindActionCreators(removeAction, dispatch),
editRow: bindActionCreators(editAction, dispatch),
closeNotif: bindActionCreators(closeNotifAction, dispatch),
+ dispatch
});
const CrudPedidoMapped = connect(
diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js
index 2e2b003..e16f7cc 100644
--- a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js
+++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js
@@ -4,10 +4,10 @@ export const anchorTable = [
label: 'Id',
initialValue: '',
hidden: true,
- type: 'texto'
}, {
name: 'cantidad',
label: 'Cantidad',
+ initialValue: 0,
width: 'auto',
hidden: false,
type: 'texto'
@@ -21,28 +21,28 @@ export const anchorTable = [
}, {
name: 'origen',
label: 'Origen',
- initialValue: 'option1',
+ initialValue: 'Lima',
width: 'auto',
hidden: false,
type: 'texto'
}, {
name: 'destino',
label: 'Destino',
- initialValue: 'option1',
+ initialValue: 'Lima',
width: 'auto',
hidden: false,
type: 'texto'
}, {
name: 'plazo_entrega',
label: 'Plazo de entrega',
- initialValue: true,
+ initialValue: 'aja',
width: 'auto',
hidden: false,
type: 'texto'
}, {
name: 'nombre',
label: 'Cliente',
- initialValue: true,
+ initialValue: null,
width: 'auto',
hidden: false,
type: 'texto'
@@ -53,7 +53,8 @@ export const anchorTable = [
width: 'auto',
hidden: false,
type: 'etiq_pedido'
- }, {
+ },
+ {
name: 'action',
label: 'Action',
initialValue: '',
@@ -65,8 +66,9 @@ export const dataApi = [
{
id: '1',
cantidad: 30,
- fecha: '24/05/2022 11:28 AM',
+
origen: 'Arequipa',
+ fecha: '24/05/2022 11:28 AM',
destino: 'Cuzco',
plazo_entrega: '24 horas',
nombre: 'Juan',
diff --git a/front/odiparpack/app/containers/Tables/demos/sampleData.js b/front/odiparpack/app/containers/Tables/demos/sampleData.js
index d53d8e2..c783c81 100644
--- a/front/odiparpack/app/containers/Tables/demos/sampleData.js
+++ b/front/odiparpack/app/containers/Tables/demos/sampleData.js
@@ -9,53 +9,62 @@ export const anchorTable = [
label: 'Text Field',
initialValue: null,
width: 'auto',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'email',
label: 'Email Field',
initialValue: null,
width: 'auto',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'radio',
label: 'Radio Option',
initialValue: 'option1',
width: '80',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'selection',
label: 'Selection',
initialValue: 'option1',
width: '80',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'onof',
label: 'On/Of Input',
initialValue: true,
width: '80',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'checkbox',
label: 'Checkbox',
initialValue: true,
width: '80',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'textarea',
label: 'Text Area',
initialValue: 'This is default text',
width: 'auto',
- hidden: false
+ hidden: false,
+ type:"texto"
}, {
name: 'edited',
label: '',
initialValue: '',
- hidden: true
+ hidden: true,
+ type:"texto"
}, {
name: 'action',
label: 'Action',
initialValue: '',
- hidden: false
+ hidden: false,
+ type:"texto"
},
];
diff --git a/front/odiparpack/app/redux/configureStore.js b/front/odiparpack/app/redux/configureStore.js
index 49a6b7b..80c84c0 100644
--- a/front/odiparpack/app/redux/configureStore.js
+++ b/front/odiparpack/app/redux/configureStore.js
@@ -7,6 +7,7 @@ import { fromJS } from 'immutable';
import { routerMiddleware } from 'connected-react-router/immutable';
import createSagaMiddleware from 'redux-saga';
import createReducer from './reducers';
+import thunk from 'redux-thunk';
const sagaMiddleware = createSagaMiddleware();
@@ -14,7 +15,7 @@ export default function configureStore(initialState = {}, history) {
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
- const middlewares = [sagaMiddleware, routerMiddleware(history)];
+ const middlewares = [thunk,sagaMiddleware, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
@@ -29,11 +30,12 @@ export default function configureStore(initialState = {}, history) {
shouldHotReload: false,
})
: compose;
+
/* eslint-enable */
const store = createStore(
createReducer(),
fromJS(initialState),
- composeEnhancers(...enhancers),
+ composeEnhancers(...enhancers)
);
// Extensions
diff --git a/front/odiparpack/app/redux/modules/crudTableForm.js b/front/odiparpack/app/redux/modules/crudTableForm.js
index d5194c1..29b9813 100644
--- a/front/odiparpack/app/redux/modules/crudTableForm.js
+++ b/front/odiparpack/app/redux/modules/crudTableForm.js
@@ -24,6 +24,7 @@ const initialItem = (keyTemplate, anchor) => {
for (let i = 0; i < rawKey.length; i += 1) {
if (rawKey[i] !== 'id') {
const itemIndex = anchor.findIndex(a => a.name === rawKey[i]);
+ if (itemIndex == -1) continue
staticKey[rawKey[i]] = anchor[itemIndex].initialValue;
}
}
diff --git a/front/odiparpack/app/redux/modules/message.js b/front/odiparpack/app/redux/modules/message.js
new file mode 100644
index 0000000..e02eb08
--- /dev/null
+++ b/front/odiparpack/app/redux/modules/message.js
@@ -0,0 +1,30 @@
+import { CLOSE_MESSAGE,OPEN_MESSAGE } from 'ba-actions/actionTypes';
+
+const initState = {
+ message: '',
+ type: '',
+ openMessage: false
+}
+
+const message = (state = initState, action = {}) => {
+
+ const { type, payload } = action;
+
+ switch (type) {
+
+ case CLOSE_MESSAGE:
+ return {...initState}
+ case OPEN_MESSAGE:
+ return {
+ ...state,
+ ...payload,
+ openMessage: true
+ }
+ default:
+ return state
+
+ }
+
+}
+
+export default message;
\ No newline at end of file
diff --git a/front/odiparpack/app/redux/modules/pedido.js b/front/odiparpack/app/redux/modules/pedido.js
new file mode 100644
index 0000000..9101fe4
--- /dev/null
+++ b/front/odiparpack/app/redux/modules/pedido.js
@@ -0,0 +1,16 @@
+import { LISTA_PEDIDO } from 'ba-actions/actionTypes';
+
+const initState = {
+ pedidos : []
+}
+
+const pedido = (state = initState, action) => {
+ switch (action.type) {
+ case LISTA_PEDIDO:
+ return { ...state, pedidos: action.payload }
+ default :
+ return state
+ }
+}
+
+export default pedido;
\ No newline at end of file
diff --git a/front/odiparpack/app/redux/reducers.js b/front/odiparpack/app/redux/reducers.js
index 7327c48..e0e2547 100644
--- a/front/odiparpack/app/redux/reducers.js
+++ b/front/odiparpack/app/redux/reducers.js
@@ -20,6 +20,10 @@ import email from './modules/email';
import calendar from './modules/calendar';
import initval from './modules/initForm';
+//Odipar
+import pedido from './modules/pedido';
+import message from './modules/message'
+
/**
* Branching reducers to use one reducer for many components
*/
@@ -56,6 +60,8 @@ export default function createReducer(injectedReducers) {
crudTableForm,
crudTbFrmDemo: branchReducer(crudTableForm, 'crudTbFrmDemo'),
crudPedido: branchReducer(crudTableForm, 'crudPedido'),
+ pedido,
+ message,
language: languageProviderReducer,
router: connectRouter(history),
...injectedReducers,
diff --git a/front/odiparpack/app/utils/odipar/api.js b/front/odiparpack/app/utils/odipar/api.js
new file mode 100644
index 0000000..ea5e617
--- /dev/null
+++ b/front/odiparpack/app/utils/odipar/api.js
@@ -0,0 +1,113 @@
+import Axios from 'axios'
+import {apiUrl} from './constants';
+import qs from "query-string";
+import { openSuccessMessage, openErrorMessage } from 'ba-actions/message';
+
+export function getHeaders() {
+ let session = getSession();
+ return {
+ //Authorization: `Token ${(session && session.accessToken) || null}`
+ }
+}
+
+
+export function getSession() {
+ if (window && window.localStorage) {
+ return window.localStorage.getObject('session');
+ }
+
+ return null;
+}
+
+export function saveSession(value) {
+ if (window && window.localStorage) {
+ return window.localStorage.saveObject('session', value);
+ }
+
+ return null;
+}
+
+export function apiReq(endPoint, data, method, headers, requestOptions = {}) {
+ return new Promise((res, rej) => {
+
+ headers = {
+ ...headers
+ }
+ if (method === 'get' || method === 'delete') {
+ data = {
+ ...requestOptions,
+ params: data,
+ paramsSerializer: function (params) {
+ return qs.stringify(params, { arrayFormat: 'repeat' })
+ },
+ headers
+ }
+ }
+
+ Axios[method](endPoint, data, { headers }).then((result) => {
+ let { data } = result;
+ console.log("aca en la promesa ps")
+ if (data.status === false) {
+ return rej(data);
+ }
+
+ return res(data);
+ }).catch((err) => {
+ return rej(err);
+ });
+ })
+}
+
+export function generateUrl(path) {
+ return apiUrl + path;
+}
+
+export function apiPost(endPoint, data, headers = {}) {
+ return apiReq(generateUrl(endPoint), data, 'post', headers);
+}
+
+export function apiDelete(endPoint, data, headers = {}) {
+ return apiReq(generateUrl(endPoint), data, 'delete', headers);
+}
+
+export function apiGet(endPoint, data, headers = {}, requestOptions) {
+ return apiReq(generateUrl(endPoint), data, 'get', headers, requestOptions);
+}
+
+export function apiPut(endPoint, data, headers = {}) {
+ return apiReq(generateUrl(endPoint), data, 'put', headers);
+}
+
+
+export function addMessageCurry(promise, dispatch, errorMsg = '', successMsg = '', showError = true) {
+ return new Promise(
+ (resolve, reject) => {
+
+ promise
+ .then(response => {
+
+ if (successMsg) {
+ console.log("mensajitooooo=?????")
+ dispatch(
+ openSuccessMessage(successMsg)
+ )
+ }
+
+ resolve(response)
+ })
+ .catch(
+ err => {
+ if(showError) {
+ dispatch(
+ openErrorMessage(errorMsg || ((err.response && err.response.data.message) || 'Server encountered an error'))
+ )
+ }
+
+ reject(err)
+ }
+ )
+
+ }
+ )
+
+}
\ No newline at end of file
diff --git a/front/odiparpack/app/utils/odipar/constants.js b/front/odiparpack/app/utils/odipar/constants.js
new file mode 100644
index 0000000..73f3521
--- /dev/null
+++ b/front/odiparpack/app/utils/odipar/constants.js
@@ -0,0 +1,9 @@
+//export const apiUrl = `${config.api}api/v1/`;
+export const apiUrl = 'http://localhost:8083/';
+
+//mensaje
+export function partial(fn, ...presetArgs) {
+ return function partiallyApplied(...laterArgs) {
+ return fn(...presetArgs, ...laterArgs);
+ };
+}
\ No newline at end of file
diff --git a/front/odiparpack/app/utils/odipar/menu.js b/front/odiparpack/app/utils/odipar/menu.js
new file mode 100644
index 0000000..eca2600
--- /dev/null
+++ b/front/odiparpack/app/utils/odipar/menu.js
@@ -0,0 +1,51 @@
+module.exports = [
+ {
+ key: 'seguimiento',
+ name: 'Seguimiento',
+ icon: 'near_me',
+ link: '/app/dashboard-v2',
+ child: [ ]
+ },
+ {
+ key: 'pedidos',
+ name: 'Pedidos',
+ icon: 'inventory_2',
+ link: '/app/pedidos',
+ child: [ ]
+ },
+ {
+ key: 'camiones',
+ name: 'Camiones',
+ icon: 'local_shipping',
+ link: '/app/layouts/grid',
+ child: [ ]
+ },
+ {
+ key: 'almacenes',
+ name: 'Almacenes',
+ icon: 'warehouse',
+ link: '/app/tables/crud-table',
+ child: [ ]
+ },
+ {
+ key: 'red_tramos',
+ name: 'Red de Tramos',
+ icon: 'location_on',
+ link: '/app/forms/reduxform',
+ child: [ ]
+ },
+ {
+ key: 'otros',
+ name: 'Otros parámetros',
+ icon: 'settings',
+ link: '/app/ui/icons',
+ child: [ ]
+ },
+ {
+ key: 'simulacion',
+ name: 'Simulación',
+ icon: 'fast_forward',
+ link: '/app/pages/calendar',
+ child: [ ]
+ }
+ ];
\ No newline at end of file
diff --git a/front/odiparpack/internals/webpack/webpack.base.babel.js b/front/odiparpack/internals/webpack/webpack.base.babel.js
index ca26c12..89ff730 100644
--- a/front/odiparpack/internals/webpack/webpack.base.babel.js
+++ b/front/odiparpack/internals/webpack/webpack.base.babel.js
@@ -197,6 +197,7 @@ module.exports = options => ({
'ba-api': path.resolve(__dirname, '../../app/api/'),
'ba-images': path.resolve(__dirname, '../../public/images/'),
'ba-vendor': path.resolve(__dirname, '../../node_modules/'),
+ 'odi-utils': path.resolve(__dirname,'../../app/utils/odipar/')
}
},
devtool: options.devtool,
diff --git a/front/odiparpack/package-lock.json b/front/odiparpack/package-lock.json
index bf01861..ff64c1f 100644
--- a/front/odiparpack/package-lock.json
+++ b/front/odiparpack/package-lock.json
@@ -6069,8 +6069,7 @@
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
- "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
- "dev": true
+ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
},
"decompress-zip": {
"version": "0.3.2",
@@ -7772,6 +7771,11 @@
}
}
},
+ "filter-obj": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
+ "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs="
+ },
"finalhandler": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
@@ -13963,6 +13967,17 @@
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
+ "query-string": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.1.tgz",
+ "integrity": "sha512-MplouLRDHBZSG9z7fpuAAcI7aAYjDLhtsiVZsevsfaHWDS2IDdORKbSd1kWUA+V4zyva/HZoSfpwnYMMQDhb0w==",
+ "requires": {
+ "decode-uri-component": "^0.2.0",
+ "filter-obj": "^1.1.0",
+ "split-on-first": "^1.0.0",
+ "strict-uri-encode": "^2.0.0"
+ }
+ },
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
@@ -15204,6 +15219,11 @@
"symbol-observable": "^1.2.0"
}
},
+ "redux-devtools-extension": {
+ "version": "2.13.9",
+ "resolved": "https://registry.npmjs.org/redux-devtools-extension/-/redux-devtools-extension-2.13.9.tgz",
+ "integrity": "sha512-cNJ8Q/EtjhQaZ71c8I9+BPySIBVEKssbPpskBfsXqb8HJ002A3KRVHfeRzwRo6mGPqsm7XuHTqNSNeS1Khig0A=="
+ },
"redux-form": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/redux-form/-/redux-form-8.2.0.tgz",
@@ -15244,6 +15264,11 @@
"@redux-saga/core": "^1.0.2"
}
},
+ "redux-thunk": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
+ "integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q=="
+ },
"reflect.ownkeys": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz",
@@ -16596,6 +16621,11 @@
"integrity": "sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==",
"dev": true
},
+ "split-on-first": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
+ "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw=="
+ },
"split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
@@ -16749,6 +16779,11 @@
"stream-to": "~0.2.0"
}
},
+ "strict-uri-encode": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
+ "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
+ },
"string-argv": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.0.2.tgz",
diff --git a/front/odiparpack/package.json b/front/odiparpack/package.json
index 7e9a59a..480d0a7 100644
--- a/front/odiparpack/package.json
+++ b/front/odiparpack/package.json
@@ -136,6 +136,7 @@
"minimist": "1.2.0",
"mui-datatables": "^2.13.1",
"prop-types": "15.7.2",
+ "query-string": "^7.1.1",
"rcolor": "^1.0.1",
"react": "16.8.6",
"react-anchor-link-smooth-scroll": "^1.0.11",
@@ -171,9 +172,11 @@
"recharts": "^1.5.0",
"recompose": "^0.28.2",
"redux": "4.0.1",
+ "redux-devtools-extension": "^2.13.9",
"redux-form": "8.2.0",
"redux-immutable": "4.0.0",
"redux-saga": "1.0.2",
+ "redux-thunk": "^2.4.1",
"reselect": "4.0.0",
"sanitize.css": "8.0.0",
"serve-favicon": "^2.4.5",
--
cgit v1.2.3