import {connect} from 'react-redux';
import {add_dialog_msg, get_iogroup_list, del_iogroup, edit_iogroup, add_iogroup, get_select_list,clear_iogroup, clear_select_list} from '../../actions';
import IOGroupPage from '../../components/AdminPage/IOGroup';

const mapStateToProps = (state) => ({
	i18n: state.i18n,
	list: state.lists.iogroup.list,
	dos: state.lists.iogroup.do,
	leones: state.lists.iogroup.leone,
	permissions: (function() {
        let p = sessionStorage.getItem('permissions');
        if (!p) return {};
        let json = {};
        try {
            json = JSON.parse(p);
        } catch (e) {
            return {};
        }
        return json
    }()),
	devs: state.lists.selectdev
});

const mapDispatchToProps = (dispatch, ownProps) => ({
	showDialog: (msg) => {
		dispatch(add_dialog_msg(msg));
	},
	clearList: () => {
		dispatch(clear_iogroup());
	},
	getIOGroupList: () => {
		dispatch(get_iogroup_list());
	},
	addIOGroup: (data) => {
		dispatch(add_iogroup(data));
	},
	editIOGroup: (data) => {
		dispatch(edit_iogroup(data));
	},
	delIOGroup: (data) => {
		dispatch(del_iogroup(data));
	},
	getSelectList: (data) => {
		dispatch(get_select_list(data));
	},
	clearSelectList: () => {
		dispatch(clear_select_list());
	}
})

export default connect(mapStateToProps, mapDispatchToProps)(IOGroupPage);