client/src/reducers/notesReducer.js
author Alexandre Segura <mex.zktk@gmail.com>
Wed, 31 May 2017 17:51:54 +0200
changeset 12 48ddaa42b810
parent 3 3b5d37d84cfe
child 29 4cfeabef7d5e
permissions -rw-r--r--
Draft implementation of sessions. - Introduce react-router & add some pages. - Add login page (does nothing). - Allow creating a new session. - Allow adding notes into a session.

import Immutable from 'immutable';
// import PouchDB from 'pouchdb';

import * as types from '../constants/actionTypes';
import noteRecord from '../store/noteRecord';

// const db = new PouchDB('notes');

// db.allDocs({ include_docs: true, descending: true }, function(err, doc) {
//   console.log(doc.rows)
// });

export default (state = Immutable.List([]), action) => {
  switch (action.type) {
    case types.ADD_NOTE:
      return state.push(new noteRecord(action.note));
    default:
      return state;
  }
};