123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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_REGISTRATION_EVENT,
- payload
- });
- export const regEventSuccess = payload => ({
- type: types.POST_REGISTRATION_EVENT_SUCCESS,
- payload
- });
- export const regEventError = payload => ({
- type: types.POST_REGISTRATION_EVENT_ERROR,
- payload
- });
- export const regEventSubmit = payload => {
- console.log('post');
- return dispatch => {
- let promise = fetch(urlRegEvent,
- {
- method: 'POST',
- body: JSON.stringify(payload),
- headers: {
- "Content-type": "application/json"
- }
- }
- )
- dispatch(regEvent())
- promise.then(
- data => data.json().then(data => dispatch(regEventSuccess(data))),
- 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))
- )
- }
- }*/
|