{"size": 977, "ext": "js", "max_stars_repo_path": "frontend/src/store/actions/tasks/update.js", "max_stars_repo_name": "emushell/django-rest-react-todo-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "frontend/src/store/actions/tasks/update.js", "max_issues_repo_name": "emushell/django-rest-react-todo-app", "max_issues_repo_issues_event_min_datetime": "2021-03-18T23:42:28.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T00:15:38.000Z", "max_forks_repo_path": "frontend/src/store/actions/tasks/update.js", "max_forks_repo_name": "emushell/django-rest-react-todo-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 24.425, "max_line_length": 68, "alphanum_fraction": 0.5312180143}
import * as actionTypes from '../actionTypes';
import { putTask } from '../../services';


export const taskUpdateStart = () => {
    return {
        type: actionTypes.TASK_UPDATE_START
    };
};

export const taskUpdateSuccess = (task) => {
    return {
        type: actionTypes.TASK_UPDATE_SUCCESS,
        task: task
    };
};

export const taskUpdateFail = (error) => {
    return {
        type: actionTypes.TASK_UPDATE_FAIL,
        error: error
    };
};

export const updateTask = (task) => {
    return (dispatch) => {
        dispatch(taskUpdateStart(task));
        return putTask(task)
            .then(data => {
                dispatch(taskUpdateSuccess(data));
            })
            .catch(error => {
                const { data, status, statusText } = error.response;
                let errorResponse = {
                    data, status, statusText
                };
                dispatch(taskUpdateFail(errorResponse));
            });
    };
};