Example #1
0
import {
  FILE_SAVE
} from './constants'

import { createReducer } from 'commons/utils'

export default createReducer({}, {
  [FILE_SAVE.REQUEST]: (state, action) => {
    return {
      ...state,
      progress: true,
      uploading: {
        ...state.uploading,
        [ action.fileUploadId ]: true
      }
    }
  },

  [FILE_SAVE.SUCCESS]: (state, action) => {
    return {
      ...state,
      progress: false,
      uploading: {
        ...state.uploading,
        [ action.fileUploadId ]: null
      },
      [action.result.body.id]: action.result.body
    }
  }
})
Example #2
0
import {SET_PAGE_PROPS} from "./constants";
import {RESOLVE_ROUTE_START} from "commons/resolve/redux/constants";
import {createReducer} from "commons/utils";

export default createReducer({}, {
  [SET_PAGE_PROPS]: (state, action) => {
    return {
      ...state,
      title: action.title,
      meta: action.meta || [],
      link: action.link || []
    }
  }
})
Example #3
0
export default createReducer({prevPath: []}, {
  [RESOLVED_ON_SERVER]: (state, action) => ({
    ...state,
    isClientFirstResolve: true
  }),

  [RESOLVE_ROUTE_START]: (state, action) => ({
    ...state,
    resolving: true
  }),

  [RESOLVE_ROUTE_END]: (state, action) => ({
    ...state,
    keepResolve: false,
    resolving: !!state.keepResolve,
    isClientFirstResolve: false
  }),

  [RESOLVE_SET_PREV_PATH]: (state, action) => ({
    ...state,
    prevPath: action.path
  }),

  [RESOLVE_KEEP]: (state, action) => ({
    ...state,
    keepResolve: true
  }),

  [RESOLVE_SAGA_START]: (state, action) => ({
    ...state,
    currentSaga: action.name
  }),

  [RESOLVE_SAGA_END]: (state, action) => ({
    ...state,
    currentSaga: null
  }),

  [HISTORY_CHANGE]: (state, action) => action.state && ({
    ...state,
    query: action.state.location.query || (action.state.location.search && queryString.parse(action.state.location.search)) || {},
    params: action.state.params,
    pathname: action.state.location.pathname,
    resolving: true
  }) || ({
    ...state,
    resolving: true
  })
})