updateItem(state: Map<string, Record<Object>>, action: Object): Map<string, Record<Object>> { state = state.setIn([action.id, 'name'], action.name); state = state.sortBy(item => item.name); ItemData.setState(state); return state; }
export function setMetaForce(appName, meta, appQuery) { if (!appName || !meta) return meta = (Immutable.isMap(meta) || Immutable.isList(meta)) ? meta : fromJS(meta) //meta = fromJS(meta) meta = parseMetaTemplate(meta) var parsed = parseMeta(meta, appName) meta = parsed.meta var map = parsed.map if (appQuery) { cache.meta = cache.meta .setIn([appName, appQuery, 'meta'], meta) .setIn([appName, appQuery, 'metaMap'], map) } else { cache.meta = cache.meta .setIn([appName, 'meta'], meta) .setIn([appName, 'metaMap'], map) } }
handleActions({ [ActionTypes.CREATE_TODO]: (state, { payload }) => { const id = payload.id; const updatedAt = payload.updatedAt; const newState = state.setIn(['todo', 'id'], id) .setIn(['todo', 'updatedAt'], updatedAt); const todos = state.get('todos').concat(newState.get('todo')); return state.set('todos', todos) .setIn(['todo', 'text'], ''); }, [ActionTypes.DELETE_TODO]: (state, { payload }) => { const deleteTodo = state.get('todos')[payload.index]; const todos = state.get('todos').filter((o) => o !== deleteTodo); return state.set('todos', todos); }, [ActionTypes.SET_TODO]: (state, { payload }) => ( state.setIn(['todo', 'text'], payload.text) ), }, initialState)
const CheckListReducer = (state = initialState, action) => { let newList; switch (action.type) { case ActionTypes.ADD_ITEM: newList = state.collection.push( new CheckListItem({ name: action.payload }), ); return state.setIn(['collection'], newList); case ActionTypes.REMOVE_ITEM: newList = state.collection.removeIn([action.payload]); return state.setIn(['collection'], newList); case ActionTypes.TOGGLE_ITEM: newList = state.collection.update( action.payload, val => new CheckListItem({ name: val.name, checked: !val.checked }), ); return state.setIn(['collection'], newList); default: return state; } }
export default function things(state = initialState, action) { switch (action.type) { case SET_THING_NAME: return state.setIn(['options', action.idx, 'name'], action.name); case ADD_THING: return state.updateIn( ['options'], list => list.push(Map({ id: action.id, name: action.name })) ); case REMOVE_THING: return state.updateIn( ['options'], list => list.filter(thing => String(thing.get('id')) !== String(action.id)) ); case THING_SIGN_UP: return state.set('signedUp', true); case THING_SIGN_UP_RESET: return state.set('signedUp', false); default: return state; } }
const editDescription = (state: State, { payload }: descriptionPayload) => state.setIn([payload.id, 'description'], payload.description)
case types.VALUE_CHANGED: return state.withMutations(map => { map.setIn([ 'values', action.id ],action.value) .deleteIn([ 'errors', action.id ]) })
return state.setIn( [action.pid, action.id], List.of(Map({
case RESET_PASSWORD_REQUEST: { let nextState = state .setIn(['form', 'isFetching'], true) .setIn(['form', 'error'], null) return nextState state.setIn(['form', 'state'], action.type) .setIn(['form', 'error'], null) .setIn(['form', 'fields', 'username'], '') .setIn(['form', 'fields', 'email'], '') .setIn(['form', 'fields', 'password'], '') .setIn(['form', 'fields', 'passwordAgain'], '') case FORGOT_PASSWORD: return formValidation( state.setIn(['form', 'state'], action.type) .setIn(['form', 'error'], null) let nextState = state.setIn(['form', 'fields', field], value) .setIn(['form', 'error'], null) case LOGOUT_SUCCESS: case RESET_PASSWORD_SUCCESS: return state.setIn(['form', 'isFetching'], false) case LOGIN_FAILURE: case RESET_PASSWORD_FAILURE: return state.setIn(['form', 'isFetching'], false) .setIn(['form', 'error'], action.payload)
return state.setIn(['form', 'isFetching'], true) .setIn(['form', 'error'], null) return state.setIn(['form', 'isFetching'], false) nextProfileState = state.setIn(['form', 'isFetching'], false) .setIn(['form', 'fields', 'username'], action.payload.username) .setIn(['form', 'fields', 'email'], action.payload.email) .setIn(['form', 'fields', 'emailVerified'], action.payload.emailVerified) .setIn(['form', 'originalProfile', 'username'], action.payload.username) .setIn(['form', 'originalProfile', 'email'], action.payload.email) .setIn(['form', 'originalProfile', 'emailVerified'], action.payload.emailVerified) .setIn(['form', 'originalProfile', 'objectId'], action.payload.objectId) .setIn(['form', 'error'], null) nextProfileState = state.setIn(['form', 'fields', 'username'], '') .setIn(['form', 'fields', 'email'], '') .setIn(['form', 'fields', 'emailVerified'], false) .setIn(['form', 'originalProfile', 'username'], '') .setIn(['form', 'originalProfile', 'email'], '') .setIn(['form', 'originalProfile', 'emailVerified'], false) .setIn(['form', 'originalProfile', 'objectId'], null) .setIn(['form', 'error'], null) return formValidation(nextProfileState, action) return state.setIn(['form', 'isFetching'], false) .setIn(['form', 'error'], action.payload)
updateItem(state: Map<string, ItemType>, action: Object): Map<string, ItemType> { state = state.setIn([action.id, 'name'], action.name); state = state.sortBy(item => item.name); return state; }