client/src/actions/sessionsActions.js
changeset 58 f16a080e0bc4
parent 30 4d93f4ed95bc
child 59 1eb52770eefa
equal deleted inserted replaced
57:2e4e9f9ebc4f 58:f16a080e0bc4
     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: "http://localhost:8000/api/notes/sessions/",
       
    23           body: JSON.stringify(newSession), method: 'POST',
       
    24           headers: {
       
    25             Authorization: "JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJlbWFpbCI6IiIsInVzZXJuYW1lIjoieW1oIiwiZXhwIjoxNDk3NjU2MjY5fQ.qrwbC4oRqvWNOp8x_8yZRJJowVVoFEpjy1uLhiERTTI"
       
    26           }
       
    27         },
       
    28         commit: { type: types.CREATE_SESSION_ASYNC },
       
    29         rollback: { type: 'NoOp'}
       
    30       }
    13     }
    31     }
    14   };
    32   };
    15 }
    33 }
    16 
    34 
    17 export const updateSession = (session, values) => {
    35 export const updateSession = (session, values) => {
    18   return {
    36   return {
    19     type: types.UPDATE_SESSION_ASYNC,
    37     type: types.UPDATE_SESSION,
    20     session: session,
    38     session: session,
    21     values: values,
    39     values: values,
    22   };
    40   };
    23 }
    41 }
    24 
    42 
    25 export const loadSessions = () => {
    43 export const loadSessions = () => {
    26   return {
    44   return {
    27     type: types.LOAD_SESSIONS_ASYNC
    45     type: types.LOAD_SESSIONS
    28   }
    46   }
    29 }
    47 }