client/src/actions/notesActions.js
author ymh <ymh.work@gmail.com>
Sat, 06 Jul 2019 00:59:32 +0200
changeset 203 b378ca8d67af
parent 132 906a6c7c7943
permissions -rw-r--r--
Added tag 0.2.2 for changeset 2c1d48085efc

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 };
}