export default {
    namespace: 'dataList',
    state: {
        columns: [],
        dataSource: [],

        loading: false,
        pageSize: 25,
        total: 0,
    },
    reducers: {
        setField(state, action) {
            const { name, value } = action;
            let obj = {};
            obj[name] = value;
            let newState = Object.assign({}, state, obj);
            return Object.assign({}, newState);
        },
        setFields(state, action) {
            const { fields } = action;
            let obj = {};
            fields.map(f => (obj[f.name] = f.value));
            let newState = Object.assign({}, state, obj);
            return Object.assign({}, newState);
        },
        setColumns(state, action) {
            const { columns } = action;
            return { ...state, columns }
        },
        setDataSource(state, action) {
            const { dataSource } = action;
            return { ...state, dataSource }
        },
        reset(state, action) {
            return { ...state, columns: [], dataSource: [] }
        }
    },
    effects: {
    },
};