diff --git a/src/actions/statistics.js b/src/actions/statistics.js index a69428170d3b248bd2096e828844b27ec7f6ff79..5e378a9d2b7d35ad65f97f5c938cc8dbd5e7f7c9 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -1,5 +1,5 @@ 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); + } + } +); diff --git a/src/actions/types.js b/src/actions/types.js index c551d293f3ff427b0a98099e03a80d9a9a0fd0ee..3a3c635422f970703c2dba670def81a424e48f0d 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -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';