import * as constants from './constants';
import { fromJS } from 'immutable';

import axios from '../../../common/axios_auth.js';
// import axios from 'axios';



//actionType
export const searchFocus = () => ({
    type: constants.SEARCH_FOCUS
});

export const getList = () => {
    return (dispatch) => {
        axios.get('/api/submenuList.json').then((res) => {
            const data = res.data;
            dispatch(changeList(data.data));
        }).catch(() => {
            console.log('error');
        })
    }
};

export const changeInputValue = (value) => (  {
    type: constants.CHANGE_INPUTVALUE,
    data:fromJS(value),
});

const changeList = (data) => ({
    type: constants.CHANGE_LIST,
    data: fromJS(data),
    // totalPage: Math.ceil(data.length / 10)
});

// export const searchBlur = () => ({
// 	type: constants.SEARCH_BLUR
// });

// export const mouseEnter = () => ({
// 	type: constants.MOUSE_ENTER
// });

// export const mouseLeave = () => ({
// 	type: constants.MOUSE_LEAVE
// });

// export const changePage = (page) => ({
// 	type: constants.CHANGE_PAGE,
// 	page
// });

