client/src/actions/notesActions.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 132 906a6c7c7943
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters

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