client/src/actions/sessionsActions.js
changeset 62 b2514a9bcd49
parent 59 1eb52770eefa
child 66 f402435be429
equal deleted inserted replaced
61:7586b4a11c32 62:b2514a9bcd49
     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 createSession = () => {
     5 export const createSession = (sessionId) => {
     6   return {
     6 
     7     type: types.CREATE_SESSION_ASYNC,
     7   //const sessionId = uuidV1();
     8     session: {
     8   const newSession = {
     9       _id: uuidV1(),
     9       _id: sessionId,
       
    10       ext_id: sessionId,
    10       date: new Date(),
    11       date: new Date(),
    11       title: '',
    12       title: '',
    12       description: '',
    13       description: '',
       
    14   };
       
    15 
       
    16   return {
       
    17     type: types.CREATE_SESSION,
       
    18     session: newSession,
       
    19     meta: {
       
    20       offline: {
       
    21         effect: {
       
    22           url: "/api/notes/sessions/",
       
    23           method: 'POST',
       
    24           data: newSession
       
    25         },
       
    26         commit: { type: types.CREATE_SESSION_ASYNC },
       
    27         rollback: { type: 'NoOp'}
       
    28       }
    13     }
    29     }
    14   };
    30   };
    15 }
    31 }
    16 
    32 
    17 export const updateSession = (session, values) => {
    33 export const updateSession = (session, values) => {
    18   return {
    34   return {
    19     type: types.UPDATE_SESSION_ASYNC,
    35     type: types.UPDATE_SESSION,
    20     session: session,
    36     session: session,
    21     values: values,
    37     values: values,
    22   };
    38   };
    23 }
    39 }
    24 
    40 
    25 export const loadSessions = () => {
    41 export const loadSessions = () => {
    26   return {
    42   return {
    27     type: types.LOAD_SESSIONS_ASYNC
    43     type: types.LOAD_SESSIONS
    28   }
    44   }
    29 }
    45 }