client/src/actions/notesActions.js
changeset 74 043477fd5c5c
parent 66 f402435be429
child 78 49c5ea36d0a4
equal deleted inserted replaced
73:7e8cdc74d86f 74:043477fd5c5c
     1 import uuidV1 from 'uuid/v1';
     1 import uuidV1 from 'uuid/v1';
     2 
     2 
     3 import * as types from '../constants/actionTypes';
     3 import * as types from '../constants/actionTypes';
     4 
     4 
     5 export const addNote = (session, data) => {
     5 export const addNote = (session, data) => {
       
     6   const noteId = uuidV1();
       
     7   const note = {
       
     8     _id: noteId,
       
     9     session: session._id,
       
    10     raw: data.raw,
       
    11     plain: data.plain,
       
    12     html: data.html,
       
    13     startedAt: data.startedAt,
       
    14     finishedAt: data.finishedAt,
       
    15     categories: data.categories,
       
    16   };
       
    17 
       
    18   const noteSrvr = {
       
    19     ext_id: noteId,
       
    20     session: session._id,
       
    21     raw: JSON.stringify(data.raw),
       
    22     plain: data.plain,
       
    23     html: data.html,
       
    24     tc_start: data.startedAt,
       
    25     tc_end: data.finishedAt,
       
    26     categorization: JSON.stringify(data.categories),
       
    27   }
       
    28 
     6   return {
    29   return {
     7     type: types.ADD_NOTE,
    30     type: types.ADD_NOTE,
     8     note: {
    31     note,
     9       _id: uuidV1(),
    32     meta: {
    10       session: session._id,
    33       offline: {
    11       raw: data.raw,
    34         effect: {
    12       plain: data.plain,
    35           url: `/api/notes/sessions/${session.get('_id')}/notes/`,
    13       html: data.html,
    36           method: 'POST',
    14       startedAt: data.startedAt,
    37           data: noteSrvr
    15       finishedAt: data.finishedAt,
    38         },
    16       categories: data.categories,
    39         commit: { type: types.NOOP },
       
    40         rollback: { type: types.NOOP }
       
    41       }
    17     }
    42     }
       
    43 
    18   };
    44   };
    19 }
    45 }