|
@@ -1,23 +1,55 @@
|
|
|
import * as types from "../actionTypes/actionTypes";
|
|
|
+const urlRegEvent = 'https://api-marathon.herokuapp.com/api/v1/eventUsers';
|
|
|
|
|
|
+//get
|
|
|
+export const getRegEvent = payload => ({
|
|
|
+ type: types.GET_REGISTRATION_EVENT,
|
|
|
+ payload
|
|
|
+});
|
|
|
+
|
|
|
+export const getRegEventSuccess = payload => ({
|
|
|
+ type: types.GET_REGISTRATION_EVENT_SUCCESS,
|
|
|
+ payload
|
|
|
+});
|
|
|
+
|
|
|
+export const getRegEventError = payload => ({
|
|
|
+ type: types.GET_REGISTRATION_EVENT_ERROR,
|
|
|
+ payload
|
|
|
+});
|
|
|
+
|
|
|
+export const getAllRegEvent = () => {
|
|
|
+ return dispatch => {
|
|
|
+ let promise = fetch(urlRegEvent)
|
|
|
+
|
|
|
+ dispatch(getRegEvent())
|
|
|
+
|
|
|
+ promise.then(
|
|
|
+ data => data.json().then(data => dispatch(getRegEventSuccess(data))),
|
|
|
+ error => dispatch(getRegEventError(error))
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//post
|
|
|
export const regEvent = payload => ({
|
|
|
- type: types.POST_REQUEST_CHECKIN,
|
|
|
+ type: types.POST_REGISTRATION_EVENT,
|
|
|
payload
|
|
|
});
|
|
|
|
|
|
export const regEventSuccess = payload => ({
|
|
|
- type: types.POST_REQUEST_SUCCESS_CHECKIN,
|
|
|
+ type: types.POST_REGISTRATION_EVENT_SUCCESS,
|
|
|
payload
|
|
|
});
|
|
|
|
|
|
export const regEventError = payload => ({
|
|
|
- type: types.POST_REQUEST_ERROR_CHECKIN,
|
|
|
+ type: types.POST_REGISTRATION_EVENT_ERROR,
|
|
|
payload
|
|
|
});
|
|
|
|
|
|
export const regEventSubmit = payload => {
|
|
|
+ console.log('post');
|
|
|
return dispatch => {
|
|
|
- let promise = fetch("https://api-marathon.herokuapp.com/api/v1/eventUsers",
|
|
|
+ let promise = fetch(urlRegEvent,
|
|
|
{
|
|
|
method: 'POST',
|
|
|
body: JSON.stringify(payload),
|
|
@@ -34,4 +66,43 @@ export const regEventSubmit = payload => {
|
|
|
error => dispatch(regEventError(error))
|
|
|
)
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+//put
|
|
|
+/*export const putRegEvent = payload => ({
|
|
|
+ type: types.PUT_REGISTRATION_EVENT,
|
|
|
+ payload
|
|
|
+});
|
|
|
+
|
|
|
+export const putRegEventSuccess = payload => ({
|
|
|
+ type: types.PUT_REGISTRATION_EVENT_SUCCESS,
|
|
|
+ payload
|
|
|
+});
|
|
|
+
|
|
|
+export const putRegEventError = payload => ({
|
|
|
+ type: types.PUT_REGISTRATION_EVENT_ERROR,
|
|
|
+ payload
|
|
|
+});*/
|
|
|
+
|
|
|
+//передать обьект с id юзера и обьект event
|
|
|
+/*export const putRegEventSubmit = payload => {
|
|
|
+ console.log('action',payload.value);
|
|
|
+ return dispatch => {
|
|
|
+ let promise = fetch(`${urlRegEvent}/${payload.id}`,
|
|
|
+ {
|
|
|
+ method: 'PUT',
|
|
|
+ body: JSON.stringify(payload.value),
|
|
|
+ headers: {
|
|
|
+ "Content-type": "application/json"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ dispatch(putRegEvent())
|
|
|
+
|
|
|
+ promise.then(
|
|
|
+ data => data.json().then(data => dispatch(putRegEventSuccess(data))),
|
|
|
+ error => dispatch(putRegEventError(error))
|
|
|
+ )
|
|
|
+ }
|
|
|
+}*/
|