import * as actions from './actions' ; import { omit } from 'ramda' ; import { reducerWithInitialState } from 'typescript-fsa-reducers' ; import { createAccount , removeAccount , attachEcosystem , changePassword } from './actions' ; export interface IState { [ id ] : IAccount ; } const initialState = { } ; export default reducerWithInitialState ( initialState ) . case ( createAccount . done , ( state , payload ) => ( { ... state , ... payload . result , } ) ) . case ( removeAccount . done , ( state , payload ) => omit ( [ payload . params . uniqKey ] ) ( state ) ) . case ( changePassword . done , ( state , payload ) => ( { ... state , [ payload . result . uniqKey ] : { ... payload . result , } } ) ) . case ( attachEcosystem , ( state , payload ) => ( { ... state , [ `${ state [ payload . uniqKey ] . key_id }_${ payload . ecosystemId }` ] : { ... state [ payload . uniqKey ] , ecosystem_id : payload . ecosystemId , uniqKey : `${ state [ payload . uniqKey ] . key_id }_${ payload . ecosystemId }` , } } ) ) ;