{"size": 1347, "ext": "js", "max_stars_repo_path": "yelpfe/src/store/actions/UpdateActions.js", "max_stars_repo_name": "Lambda-School-Labs/yelp-dataset-challenge-1-fe", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "yelpfe/src/store/actions/UpdateActions.js", "max_issues_repo_name": "Lambda-School-Labs/yelp-dataset-challenge-1-fe", "max_issues_repo_issues_event_min_datetime": "2021-03-10T02:12:42.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-06T08:52:58.000Z", "max_forks_repo_path": "yelpfe/src/store/actions/UpdateActions.js", "max_forks_repo_name": "Lambda-School-Labs/yelp-dataset-challenge-1-fe", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 32.0714285714, "max_line_length": 84, "alphanum_fraction": 0.6354862658}
import axios from 'axios';
import {URL} from '../constants';

export const UPDATE_START = "UPDATE_START";
export const UPDATE_SUCCESS = "UPDATE_SUCCESS";
export const UPDATE_FAILURE = "UPDATE_FAILURE";

// Update Info
export const updateProjectInfo = (userId, newInfo, token) => dispatch => {
    dispatch({ type: UPDATE_START });
    console.log('SSSSSSSSSSSSSSSSSSSSSSSSSSS',userId)
    console.log('TTTTTTTTTTTTTTTTTTTTTTTTTTT',newInfo)
    console.log('JJJJJJJJJJJJJJJJJJJJJJJJJJJ',token)
    return axios
      .put(`${URL}/api/projects/${userId}/${newInfo.id}`, JSON.stringify(newInfo), {
        headers: {'Authorization': token}
      })
      .then(res => {
        dispatch({ type: UPDATE_SUCCESS, payload: res.data });
      })
      .catch(err => {
        dispatch({ type: UPDATE_FAILURE, payload: err });
      });
  };
  
  // Update User Info
export const updateUserInfo = (newInfo, token, user) => dispatch => {
  dispatch({ type: UPDATE_START });
  console.log("newInfo", newInfo);
  console.log('token', token)
  console.log('data', user.id)
  return axios
    .put(`${URL}/api/users/${user.id}`, newInfo, {
      headers: {'Authorization': token}
    })
    .then(res => {
      dispatch({ type: UPDATE_SUCCESS, payload: res.data });
    })
    .catch(err => {
      dispatch({ type: UPDATE_FAILURE, payload: err });
    });
};