From 55c0f57d42d82f1f1f5809e9c7d6845b6e0b68af Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Wed, 25 May 2022 15:36:35 -0500 Subject: Add PedidoPage - cambio de esqueleto segun figma - componente de etiquetas - tabla y form de Pedido #TODO - estetica de etiquetas - redux y crear end points --- front/odiparpack/app/redux/reducers.js | 1 + 1 file changed, 1 insertion(+) (limited to 'front/odiparpack/app/redux') diff --git a/front/odiparpack/app/redux/reducers.js b/front/odiparpack/app/redux/reducers.js index 902ab2b..7327c48 100644 --- a/front/odiparpack/app/redux/reducers.js +++ b/front/odiparpack/app/redux/reducers.js @@ -55,6 +55,7 @@ export default function createReducer(injectedReducers) { crudTableDemo: branchReducer(crudTable, 'crudTableDemo'), crudTableForm, crudTbFrmDemo: branchReducer(crudTableForm, 'crudTbFrmDemo'), + crudPedido: branchReducer(crudTableForm, 'crudPedido'), language: languageProviderReducer, router: connectRouter(history), ...injectedReducers, -- cgit v1.2.3 From 9c396976bb42a9d41407358ce1a1d37242230f21 Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Fri, 27 May 2022 12:50:13 -0500 Subject: Add redux, dispatch and etiquetas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - estetica de etiquetas (ok) - add message, pedido Reducer - add dispatch en Componentes con connect - add api reducer que obtienen el JSON todo ok #TODO - FIX logica de añadiir - FIX axios y dispatch fuera de un componente --- front/odiparpack/app/redux/configureStore.js | 6 +++-- .../odiparpack/app/redux/modules/crudTableForm.js | 1 + front/odiparpack/app/redux/modules/message.js | 30 ++++++++++++++++++++++ front/odiparpack/app/redux/modules/pedido.js | 16 ++++++++++++ front/odiparpack/app/redux/reducers.js | 6 +++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 front/odiparpack/app/redux/modules/message.js create mode 100644 front/odiparpack/app/redux/modules/pedido.js (limited to 'front/odiparpack/app/redux') 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, -- cgit v1.2.3 From 32fb17de8f78317b165b6f269a8bab2d4e852d0d Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Mon, 30 May 2022 20:08:04 -0500 Subject: Fix axios and add new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FIX logica de añadiir (ok) - FIX axios y dispatch fuera de un componente (ok) - Cambiar las notificaciones --- front/odiparpack/app/redux/configureStore.js | 20 +++++++++++++++----- front/odiparpack/app/redux/modules/crudTableForm.js | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'front/odiparpack/app/redux') diff --git a/front/odiparpack/app/redux/configureStore.js b/front/odiparpack/app/redux/configureStore.js index 80c84c0..767af03 100644 --- a/front/odiparpack/app/redux/configureStore.js +++ b/front/odiparpack/app/redux/configureStore.js @@ -8,14 +8,15 @@ import { routerMiddleware } from 'connected-react-router/immutable'; import createSagaMiddleware from 'redux-saga'; import createReducer from './reducers'; import thunk from 'redux-thunk'; +import { composeWithDevTools } from "redux-devtools-extension"; const sagaMiddleware = createSagaMiddleware(); -export default function configureStore(initialState = {}, history) { +export 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 = [thunk,sagaMiddleware, routerMiddleware(history)]; + const middlewares = [thunk, routerMiddleware(history)]; const enhancers = [applyMiddleware(...middlewares)]; @@ -35,13 +36,13 @@ export default function configureStore(initialState = {}, history) { const store = createStore( createReducer(), fromJS(initialState), - composeEnhancers(...enhancers) + composeWithDevTools(applyMiddleware(thunk)) ); // Extensions - store.runSaga = sagaMiddleware.run; + //store.runSaga = sagaMiddleware.run; store.injectedReducers = {}; // Reducer registry - store.injectedSagas = {}; // Saga registry + //store.injectedSagas = {}; // Saga registry // Make reducers hot reloadable, see http://mxs.is/googmo /* istanbul ignore next */ @@ -53,3 +54,12 @@ export default function configureStore(initialState = {}, history) { return store; } + +export function confStore (){ + const store = createStore( + createReducer(), + composeWithDevTools(applyMiddleware(thunk)) + ); + store.injectedReducers = {}; + return store; +} diff --git a/front/odiparpack/app/redux/modules/crudTableForm.js b/front/odiparpack/app/redux/modules/crudTableForm.js index 29b9813..acf9abd 100644 --- a/front/odiparpack/app/redux/modules/crudTableForm.js +++ b/front/odiparpack/app/redux/modules/crudTableForm.js @@ -31,6 +31,19 @@ const initialItem = (keyTemplate, anchor) => { return Map(staticKey); }; + +const initialItemNew = (anchor) => { + const [...rawKey] = anchor.map((e) => e.name); + const staticKey = {}; + for (let i = 0; i < rawKey.length; i += 1) { + if (rawKey[i] !== 'id') { + staticKey[rawKey[i]] = anchor[i].initialValue; + } + } + + return Map(staticKey); +}; + let editingIndex = 0; const initialImmutableState = fromJS(initialState); @@ -46,7 +59,7 @@ export default function reducer(state = initialImmutableState, action = {}) { case `${branch}/${ADD_NEW}`: return state.withMutations((mutableState) => { const raw = state.get('dataTable').last(); - const initial = initialItem(raw, action.anchor); + const initial = initialItemNew(action.anchor); mutableState.set('formValues', initial); mutableState.set('showFrm', true); }); -- cgit v1.2.3 From cbc7d7f7494508fda69e88c76702a878bebca0e2 Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Tue, 31 May 2022 03:58:23 -0500 Subject: Add Almacenes - todo de almacenes, redux, pagina - mejoro form de pedido (etiqueta estado, RUC) #TODO - Ver combobox con API --- front/odiparpack/app/redux/modules/almacen.js | 16 ++++++++++++++++ front/odiparpack/app/redux/reducers.js | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 front/odiparpack/app/redux/modules/almacen.js (limited to 'front/odiparpack/app/redux') diff --git a/front/odiparpack/app/redux/modules/almacen.js b/front/odiparpack/app/redux/modules/almacen.js new file mode 100644 index 0000000..bb9b7d6 --- /dev/null +++ b/front/odiparpack/app/redux/modules/almacen.js @@ -0,0 +1,16 @@ +import { LISTA_ALMACEN } from 'ba-actions/actionTypes'; + +const initState = { + almacenes : [] +} + +const almacen = (state = initState, action) => { + switch (action.type) { + case LISTA_ALMACEN: + return { ...state, pedidos: action.payload } + default : + return state + } +} + +export default almacen; \ No newline at end of file diff --git a/front/odiparpack/app/redux/reducers.js b/front/odiparpack/app/redux/reducers.js index e0e2547..0c2e9b8 100644 --- a/front/odiparpack/app/redux/reducers.js +++ b/front/odiparpack/app/redux/reducers.js @@ -23,6 +23,7 @@ import initval from './modules/initForm'; //Odipar import pedido from './modules/pedido'; import message from './modules/message' +import almacen from './modules/almacen'; /** * Branching reducers to use one reducer for many components @@ -60,7 +61,9 @@ export default function createReducer(injectedReducers) { crudTableForm, crudTbFrmDemo: branchReducer(crudTableForm, 'crudTbFrmDemo'), crudPedido: branchReducer(crudTableForm, 'crudPedido'), + crudAlmacen: branchReducer(crudTableForm, 'crudAlmacen'), pedido, + almacen, message, language: languageProviderReducer, router: connectRouter(history), -- cgit v1.2.3