client/src/actions/notesActions.js
author ymh <ymh.work@gmail.com>
Tue, 01 Aug 2017 12:20:14 +0200
changeset 132 906a6c7c7943
parent 129 d48946d164c6
permissions -rw-r--r--
add group to sync + create groups + various component cleaning

import uuidV1 from 'uuid/v1';

import * as types from '../constants/actionTypes';
// import WebAnnotationSerializer from '../api/WebAnnotationSerializer';
import { ActionEnum } from '../constants';

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,
    marginComment: data.marginComment,
    action: ActionEnum.CREATED
  };

  return {
    type: types.ADD_NOTE,
    note,
  };
}

export const deleteNote = (note) => {
  return {
    type: types.DELETE_NOTE,
    note,
  };
}

export const updateNote = (note, data) => {

  return {
    type: types.UPDATE_NOTE,
    note,
    data,
  };
}

export const doDeleteNote = (noteId) => {
  return { type: types.DO_DELETE_NOTE, noteId };
}

export const doDeleteAllNote = () => {
  return { type: types.DO_DELETE_ALL_NOTE };
}

export const loadNote = (note) => {
  return { type: types.LOAD_NOTE, note };
}

export const resetActionNote = (note) => {
  return { type: types.RESET_ACTION_NOTE, note };
}