Skip to content
Snippets Groups Projects
Commit a894f3c8 authored by Chif Gergő's avatar Chif Gergő
Browse files

Create actions to create notes for events, move note actions to notes.js

parent 7289a63c
No related branches found
No related tags found
No related merge requests found
import axios from './session';
import {
GET_NOTES_BY_EVENT,
WRITE_NOTE,
ADD_NOTE,
} from './types';
export const getNotesByEvent = id => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/notes/', { params: { eventID: id } });
dispatch({
type: GET_NOTES_BY_EVENT,
payload: response.data,
});
} catch (e) {
console.log(e);
}
}
);
export const writeNote = (event) => {
return (dispatch => (dispatch({ type: WRITE_NOTE, payload: event.target.value })));
};
export const postEventNote = ({ eventid, userid, note }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/note/', {
event: eventid ? eventid : '',
user: userid ? eventid : '',
note,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_EVENT_NOTE,
payload: response.data,
});
} catch (e) {
console.log(e);
}
});
......@@ -71,20 +71,6 @@ export const visitorChange = ({ id }) => {
return (dispatch => (dispatch({ type: VISITOR_CHANGE, payload: id })));
};
export const getNotesByEvent = id => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/notes/', { params: { eventID: id } });
dispatch({
type: GET_NOTES_BY_EVENT,
payload: response.data,
});
} catch (e) {
console.log(e);
}
}
);
export const submitVisitors = ({ id, visitors }) => (
async () => {
try {
......
......@@ -22,3 +22,7 @@ export const GET_NOTES_BY_EVENT = 'get_notes_by_event';
export const WRITE_EVENT = 'write_event';
export const ADD_EVENT = 'add_event';
export const DELETE_EVENT = 'delete_event';
export const WRITE_NOTE = 'write_note';
export const CLEAR_NOTE = 'clear_note';
export const ADD_EVENT_NOTE = 'add_note';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment