diff options
Diffstat (limited to 'front/odiparpack/app/redux')
| -rw-r--r-- | front/odiparpack/app/redux/configureStore.js | 22 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/modules/almacen.js | 16 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/modules/crudTableForm.js | 16 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/modules/message.js | 30 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/modules/pedido.js | 16 | ||||
| -rw-r--r-- | front/odiparpack/app/redux/reducers.js | 10 | 
6 files changed, 104 insertions, 6 deletions
| diff --git a/front/odiparpack/app/redux/configureStore.js b/front/odiparpack/app/redux/configureStore.js index 49a6b7b..767af03 100644 --- a/front/odiparpack/app/redux/configureStore.js +++ b/front/odiparpack/app/redux/configureStore.js @@ -7,14 +7,16 @@ 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'; +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 = [sagaMiddleware, routerMiddleware(history)]; +  const middlewares = [thunk, routerMiddleware(history)];    const enhancers = [applyMiddleware(...middlewares)]; @@ -29,17 +31,18 @@ export default function configureStore(initialState = {}, history) {            shouldHotReload: false,          })        : compose; +     /* eslint-enable */    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 */ @@ -51,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/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/modules/crudTableForm.js b/front/odiparpack/app/redux/modules/crudTableForm.js index d5194c1..acf9abd 100644 --- a/front/odiparpack/app/redux/modules/crudTableForm.js +++ b/front/odiparpack/app/redux/modules/crudTableForm.js @@ -24,12 +24,26 @@ 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;      }    }    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); @@ -45,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);        }); 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 902ab2b..0c2e9b8 100644 --- a/front/odiparpack/app/redux/reducers.js +++ b/front/odiparpack/app/redux/reducers.js @@ -20,6 +20,11 @@ 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' +import almacen from './modules/almacen'; +  /**   * Branching reducers to use one reducer for many components   */ @@ -55,6 +60,11 @@ export default function createReducer(injectedReducers) {      crudTableDemo: branchReducer(crudTable, 'crudTableDemo'),      crudTableForm,      crudTbFrmDemo: branchReducer(crudTableForm, 'crudTbFrmDemo'), +    crudPedido: branchReducer(crudTableForm, 'crudPedido'), +    crudAlmacen: branchReducer(crudTableForm, 'crudAlmacen'), +    pedido, +    almacen, +    message,      language: languageProviderReducer,      router: connectRouter(history),      ...injectedReducers, | 
