summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/redux
diff options
context:
space:
mode:
authorgabrhr <[email protected]>2022-05-27 12:50:13 -0500
committergabrhr <[email protected]>2022-05-27 12:50:13 -0500
commit9c396976bb42a9d41407358ce1a1d37242230f21 (patch)
tree41b5fdf7d321f70c7e39bb788ef6ce0db6b4a6e3 /front/odiparpack/app/redux
parent55c0f57d42d82f1f1f5809e9c7d6845b6e0b68af (diff)
downloadDP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.tar.gz
DP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.tar.bz2
DP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.zip
Add redux, dispatch and etiquetas
- 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
Diffstat (limited to 'front/odiparpack/app/redux')
-rw-r--r--front/odiparpack/app/redux/configureStore.js6
-rw-r--r--front/odiparpack/app/redux/modules/crudTableForm.js1
-rw-r--r--front/odiparpack/app/redux/modules/message.js30
-rw-r--r--front/odiparpack/app/redux/modules/pedido.js16
-rw-r--r--front/odiparpack/app/redux/reducers.js6
5 files changed, 57 insertions, 2 deletions
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,