diff options
| author | gabrhr <[email protected]> | 2022-05-30 20:08:04 -0500 |
|---|---|---|
| committer | gabrhr <[email protected]> | 2022-05-30 20:08:04 -0500 |
| commit | 32fb17de8f78317b165b6f269a8bab2d4e852d0d (patch) | |
| tree | 2de1643fcda13cc5c9c0f28ffcb7a7211d9e2922 /front/odiparpack/app/redux | |
| parent | 9c396976bb42a9d41407358ce1a1d37242230f21 (diff) | |
| download | DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.tar.gz DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.tar.bz2 DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.zip | |
Fix axios and add new
- FIX logica de aƱadiir (ok)
- FIX axios y dispatch fuera de un componente (ok)
- Cambiar las notificaciones
Diffstat (limited to 'front/odiparpack/app/redux')
| -rw-r--r-- | front/odiparpack/app/redux/configureStore.js | 20 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/modules/crudTableForm.js | 15 |
2 files changed, 29 insertions, 6 deletions
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); }); |
