client/src/actions/notesActions.js
changeset 74 043477fd5c5c
parent 66 f402435be429
child 78 49c5ea36d0a4
--- a/client/src/actions/notesActions.js	Thu Jun 22 11:58:27 2017 +0200
+++ b/client/src/actions/notesActions.js	Thu Jun 22 12:09:48 2017 +0200
@@ -3,17 +3,43 @@
 import * as types from '../constants/actionTypes';
 
 export const addNote = (session, data) => {
+  const noteId = uuidV1();
+  const note = {
+    _id: noteId,
+    session: session._id,
+    raw: data.raw,
+    plain: data.plain,
+    html: data.html,
+    startedAt: data.startedAt,
+    finishedAt: data.finishedAt,
+    categories: data.categories,
+  };
+
+  const noteSrvr = {
+    ext_id: noteId,
+    session: session._id,
+    raw: JSON.stringify(data.raw),
+    plain: data.plain,
+    html: data.html,
+    tc_start: data.startedAt,
+    tc_end: data.finishedAt,
+    categorization: JSON.stringify(data.categories),
+  }
+
   return {
     type: types.ADD_NOTE,
-    note: {
-      _id: uuidV1(),
-      session: session._id,
-      raw: data.raw,
-      plain: data.plain,
-      html: data.html,
-      startedAt: data.startedAt,
-      finishedAt: data.finishedAt,
-      categories: data.categories,
+    note,
+    meta: {
+      offline: {
+        effect: {
+          url: `/api/notes/sessions/${session.get('_id')}/notes/`,
+          method: 'POST',
+          data: noteSrvr
+        },
+        commit: { type: types.NOOP },
+        rollback: { type: types.NOOP }
+      }
     }
+
   };
 }