import {REQUEST_GADGETS, RECIEVE_GADGETS} from '../../constants/dashboardConstants';

const requestGadgets = () => ({type: REQUEST_GADGETS});
const recieveGadgets = (json) => ({
        type: RECIEVE_GADGETS,
        gadgets: json
});

export const fetchGadgets = () => {
    return dispatch => {
        dispatch(requestGadgets());
        //TODO : check how to solve gadgets, don't use hardcoded values
        const gadgets = [
            {
                name: 'CustomerOrderCentral',
                idGadget: 0,        
            },
            {
                name: 'CustomerNextActions',
                idGadget: 1,
            }
        ]
        dispatch(recieveGadgets(gadgets));
        /*
        return htmlClient.fetch({
                url: `${API_SERVER}/dashboards/api/getMyDashboard`
            })
            .then(response => {
                if(response.data && response.data.gadgets){
                    dispatch(recieveGadgets(response.data.gadgets))
                }
            })
            .catch(error => {
                htmlClient.onError(error, dispatch);
            });
        */
    }
}
