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 getLockcountLIst = () => {
    return (dispatch) => {
        //axios.get(config.CLD2API+'/product/lock_store').then((res) => {
        axios.get('/api/lock_store.json').then((res) => {
            const data = res.data;
            if(data.code===200){
                let d2=data.data;
                //dispatch(changeList(JSON.parse(data.list)));
                dispatch({
                    type: constants.CHANGE_LOCKCOUNT_DATA,
                    data: fromJS(d2),
                });
            }else{
                console.log(data);
            }
        }).catch((e) => {
            console.log(e);
            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)
});