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

Add actions to handle visitors of an event

parent 6288360c
No related branches found
No related tags found
No related merge requests found
import { axios } from './auth';
import { GET_EVENTS, GET_EVENT_BY_ID } from './types';
import { GET_EVENTS, GET_EVENT_BY_ID, GET_TRAINEES, VISITOR_CHANGE, GET_NOTES_BY_EVENT } from './types';
export const getEvents = () => (
async (dispatch) => {
......@@ -28,3 +28,47 @@ export const getEventById = id => (
}
}
);
export const getTrainees = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_TRAINEES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
}
);
export const visitorChange = visitors => (
dispatch => (dispatch({ type: VISITOR_CHANGE, payload: visitors }))
);
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 {
const response = await axios.patch(`/api/v1/events/${id}/`, {
visitors
});
} catch (e) {
console.log(e);
}
}
);
......@@ -13,3 +13,9 @@ export const SELECT_NEWS = 'select_news';
export const GET_EVENTS = 'get_events';
export const GET_EVENT_BY_ID = 'get_event_by_id';
export const GET_TRAINEES = 'get_trainees';
export const GET_TRAINEE_BY_ID = 'get_trainee_by_id';
export const VISITOR_CHANGE = 'visitor_change';
export const GET_NOTES_BY_EVENT = 'get_notes_by_event';
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