import axios from "axios";
import { loadRewardFalse } from "../ListTable/ListTableActions.js";
// Export Constants
export const ADD_REWARDDATA = "ADD_REWARDDATA";
export const SETREWARDYEAR = "SETREWARDYEAR";
// Export Actions
export function addRewardData(post) {
    return {
        type: ADD_REWARDDATA,
        post
    };
}
export function setRewardYear(post) {
    return {
        type: SETREWARDYEAR,
        post
    };
}
export function postRequest(post) {
    return dispatch => {
        axios
            .post(
                "index.php?option=com_platform&task=employee.getRewardData",
                post
            )
            .then(res => {
                console.log(res.data.data);
                const data = {
                    reward_data: res.data.data.reward_data,
                    reward_data_year: res.data.data.reward_data_year
                };
                dispatch(addRewardData(data));
                dispatch(loadRewardFalse());
            })
            .catch(error => {
                console.log(error);
            });
    };
}
