如果不存在参数,如何将动作传递给另一个动作

我的代码中有2个动作。一种是根据年份月份和用户标识获取数据。

另一个是根据其他一些参数更新数据。

在第二种方法成功后,我要运行第一个操作,以便我的组件将使用更新后的内容重新呈现。

export const GetConsultantProjects = (userId, month, year) => {
    return (dispatch) => {
        dispatch({type: START_LOADING})
        globalAxios().get(`/api/v1/time_registrations`, {
            params: {
                user_id: userId,
                month: month,
                year: year
            }
        }).then(resultSet => {
            if (resultSet) {
                dispatch({type: STOP_LOADING})
                dispatch({type: GET_CONSULTANT_PROJECTS, payload: resultSet.data})
            }
        }).catch(err => {
            if (err.response) {
                console.log(err)
            }
        })
    }
}

export const UpdateProjectTime = (hour, date, projectId, userId, token, activity, timeId) => {
    let bodyFormData = new FormData();
    if(token && token.length !== 0) {bodyFormData.append('project[project_times_attributes][0][token]', token);}
    if(activity && activity.length !== 0) {bodyFormData.append('project[project_times_attributes][0][activity]', activity);}
    if(timeId && timeId.length !== 0) {bodyFormData.append('project[project_times_attributes][0][id]', timeId);}
    bodyFormData.append('project[project_times_attributes][0][user_id]', userId);
    bodyFormData.append('project[project_times_attributes][0][date]', date);
    bodyFormData.append('project[project_times_attributes][0][project_id]', projectId);
    bodyFormData.append('project[project_times_attributes][0][hours]', hour);
    return (dispatch) => {
        dispatch({type: START_LOADING})
        globalAxios().put(`/api/v1/time_registrations/${projectId}`, bodyFormData)
            .then(resultSet => {
                if (resultSet) {
                    dispatch(GetConsultantProjects()) // I want to run it again but I have no params here. How to pass them and run it again??
                    dispatch({type: UPDATE_PROJECT_TIME, payload: resultSet.data})
                    dispatch({type: STOP_LOADING})
                }
            }).catch(err => {
            if (err.response) {
                console.log(err)
            }
        })
    }
}

dispatch(GetConsultantProjects())

我想再次运行它,但是这里没有参数。像月,年和user_id。

如何通过它们并再次运行?

评论