import { actionTypes } from 'actions/wallet';
import { REHYDRATE } from 'redux-persist/constants';
import CryptoHelper from 'helper/crypto';


const handlers = {
  [actionTypes.CREATE_ITEM]: (state, action) => {
    let { items=[], ...others } = state;
    let newState = { ...others, items:  [{ a: 1 }, ...items ]}
    return newState;
  },
  [actionTypes.UPDATE_ITEM]: (state, action) => {
    return // some new state with note updated
  },
  [actionTypes.DECRYPT]: (state, action) => {
    let { items, decrypted } = state;
    if (decrypted) return state;
    if (!items) return { ...state, local: { ...state.local, decrypted: true }};
    let data = CryptoHelper.decryptItems(items);
    return { ...state, items: data, local: {
        ...state.local,
        decrypted: true,
      }
    }
  },
  [REHYDRATE]: (state, action) => {
    const { wallet } = action.payload;
    return { ...state, ...wallet };
  },
};

const Reducer = (state = {}, action) => {
  if (handlers[action.type]) {
    return handlers[action.type](state, action);
  }
  return state;
};

export default Reducer

@@ -242,24 +242,266 @@
  %7D = state;%0A
+    let newItem = %7B%0A      title: 'New login',%0A      type: 'LOGIN',%0A      createdAt: new Date(),%0A      data: %7B%0A        username: 'gaurav',%0A        password: '123456789',%0A        notes: 'some notes',%0A        website: 'google.com'%0A      %7D%0A    %7D%0A
     let newS
@@ -533,16 +533,16 @@
 :  %5B
-%7B a: 1 %7D
+ newItem
 , ..

Update reducer to create Item