client/src/actions/sessionsActions.js
author ymh <ymh.work@gmail.com>
Wed, 05 Sep 2018 12:27:52 +0200
changeset 155 e55ae84508bf
parent 135 b5aafa462956
child 168 ea92f4fe783d
permissions -rw-r--r--
Clean CreateSession component and remove trace of previous create session button

import { now } from '../utils';
import { ActionEnum } from '../constants'
import * as types from '../constants/actionTypes';


export const createSession = (sessionId, groupName, protocol, title = '', description = '') => {

  const newSession = {
      _id: sessionId,
      ext_id: sessionId,
      date: now(),
      title: title,
      description: description,
      group: groupName,
      protocol: protocol,
      action: ActionEnum.CREATED
  };

  return {
    type: types.CREATE_SESSION,
    session: newSession,
  };
}

export const updateSession = (session, values) => {
  return {
    type: types.UPDATE_SESSION,
    session: session,
    values: values,
  };
}

export const deleteSession = (session) => {
  return {
    type: types.DELETE_SESSION,
    session: session,
  };
}

export const doDeleteSession = (sessionId) => {
  return { type: types.DO_DELETE_SESSION, sessionId };
}

export const doDeleteAllSession = () => (
  { type: types.DO_DELETE_ALL_SESSION }
)

export const loadSessions = () => {
  return {
    type: types.LOAD_SESSIONS
  }
}

export const loadSession = (session) => {
  return { type: types.LOAD_SESSION, session };
}

export const resetActionSession = (session) => {
  return { type: types.RESET_ACTION_SESSION, session };
}