import { FETCH_AD_STARTED, FETCH_AD_COMPLETED, FETCH_AD_FAILED } from 'shared/constants/ActionTypes' import { createReducer } from 'shared/utils/redux-utils' const initialState = { ads: {} } export default createReducer(initialState, { [FETCH_AD_STARTED]: () => (initialState), [FETCH_AD_COMPLETED]: (state, action) => ({ ads: action.ads }), [FETCH_AD_FAILED]: (state, action) => ({ errors: action.errors }) })
export default createReducer(initialState, { [SEARCH_POST_RELOADED]: () => (initialState), [SEARCH_POST_STARTED]: () => ({ isFetching: true }), [SEARCH_POST_COMPLETED]: (state, action) => { let hasMore = false let data = state.data if (action.data) { if (action.data.length === action.limit) { hasMore = true } data = state.data.concat(action.data) } return { errors: {}, isFetching: false, data: data, offset: state.offset + action.limit, limit: action.limit, hasMore: hasMore, pattern: action.pattern } }, [SEARCH_POST_FAILED]: (state, action) => { return { errors: action.errors, isFetching: false, hasMore: false, pattern: action.pattern } }, [SEARCH_NEARBY_RELOADED]: () => (initialState), [SEARCH_NEARBY_STARTED]: () => ({ isFetching: true }), [SEARCH_NEARBY_COMPLETED]: (state, action) => { return { errors: {}, hasMore: false, isFetching: false, data: action.data, limit: action.limit, pattern: action.pattern } }, [SEARCH_NEARBY_FAILED]: (state, action) => { return { errors: action.errors, isFetching: false, hasMore: false, pattern: action.pattern } }, [SEARCH_UPDATE_CENTER_COMPLETED]: (state, action) => { return { center: action.center } } })
import { SIGNUP_USER_STARTED, SIGNUP_USER_COMPLETED, SIGNUP_USER_FAILED, GET_SITE_KEY_COMPLETED, GET_SITE_KEY_FAILED } from 'shared/constants/ActionTypes' import { createReducer } from 'shared/utils/redux-utils' const initialState = { response: {}, errors: {}, sitekey: null } export default createReducer(initialState, { [SIGNUP_USER_STARTED]: () => (initialState), [SIGNUP_USER_COMPLETED]: (state, action) => ({ response: action.response, errors: null }), [SIGNUP_USER_FAILED]: (state, action) => ({ errors: action.errors }), [GET_SITE_KEY_COMPLETED]: (state, action) => ({ sitekey: action.sitekey, errors: null }), [GET_SITE_KEY_FAILED]: (state, action) => ({ sitekey: null, errors: action.errors }) })
export default createReducer(initialState, { [LIST_CPROP_POST_RELOADED]: () => (initialState), [LIST_CPROP_POST_STARTED]: () => ({ isFetching: true }), [LIST_CPROP_POST_COMPLETED]: (state, action) => { if (action.nocontent) { return { errors: {}, titleList: action.posts, titleCprop: action.cprop, isFetching: false } } let hasMore = false if (action.posts.length === action.limit) { hasMore = true } const posts = state.posts.concat(action.posts) return { errors: {}, content: {}, posts: posts, offset: state.offset + action.limit, limit: action.limit, hasMore: hasMore, cprop: action.cprop, isFetching: false } }, [LIST_CPROP_POST_FAILED]: (state, action) => ({ isFetching: false, errors: action.errors, cprop: action.cprop }) })
export default createReducer(initialState, { [MAP_INITED]: () => (initialState), [SET_MAP_PIN_STARTED]: () => ( { ...initialState, loading: true }), [SET_MAP_PIN_COMPLETED]: (state, action) => { if (action.lat === null || action.lng === null) { return initialState } else { return { lat: action.lat, lng: action.lng, place: action.place, center: [ action.lat, action.lng ], loading: false } } }, [SET_MAP_PIN_FAILED]: (state, action) => ({ errors: action.errors }), [SET_MAP_GEO_COMPLETED]: (state, action) => ({ lat_: action.lat_, lng_: action.lng_ }), [SET_MAP_GEO_FAILED]: (state, action) => ({ errors: action.errors }), [FIND_MAP_PLACE_COMPLETED]: (state, action) => ({ lat: action.lat, lng: action.lng, place: action.place, center: [ action.lat, action.lng ] }), [FIND_MAP_PLACE_FAILED]: (state, action) => ({ errors: action.errors }) })
} from 'shared/constants/ActionTypes' import { createReducer } from 'shared/utils/redux-utils' const initialState = { errors: {}, _info: {}, orginfo: {}, _orginfo: {} } export default createReducer(initialState, { [CHANGE_PASS_USER_INITED]: (state, action) => ({ _info: {} }), [CHANGE_PASS_USER_STARTED]: () => ({ _info: {} }), [CHANGE_PASS_USER_COMPLETED]: (state, action) => ({ _info: action.info }), [CHANGE_PASS_USER_FAILED]: (state, action) => ({ errors: action.errors }), [CHANGE_INFO_USER_STARTED]: () => (initialState), [CHANGE_INFO_USER_COMPLETED]: (state, action) => ({ _orginfo: action.info }), [CHANGE_INFO_USER_FAILED]: (state, action) => ({ errors: action.errors }), [GET_INFO_USER_STARTED]: () => (initialState), [GET_INFO_USER_COMPLETED]: (state, action) => ({ orginfo: action.info }), [GET_INFO_USER_FAILED]: (state, action) => ({ errors: action.errors }) })