import {connect} from 'react-redux';
import {add_dialog_msg,
	clear_modbus,
	get_modbus_list,
	del_modbus,
	add_modbus,
	edit_modbus,
	get_mb_data,
	get_mb_iostatus,
	del_mb_iolist,
	add_mb_iolist,
	edit_mb_iolist,
	add_mb_aio,
	edit_mb_aio,
	del_mb_aio} from '../../actions';
import ModbusPage from '../../components/AdminPage/Modbus';

const mapStateToProps = (state) => ({
	i18n: state.i18n,
	list: state.lists.modbus.list || []
});

const mapDispatchToProps = (dispatch, ownProps) => ({
	showDialog: (msg) => {
		dispatch(add_dialog_msg(msg));
	},
	clearList: () => {
		dispatch(clear_modbus());
	},
	getList: () => {
		dispatch(get_modbus_list());
	},
	delModbus: (data) => {
		dispatch(del_modbus(data));
	},
	addModbus: data => {
		dispatch(add_modbus(data));
	},
	editModbus: data=>{
		dispatch(edit_modbus(data));
	},
	getMBData: data => {
		dispatch(get_mb_data(data));
	},
	getMBIOStatus: data => {
		dispatch(get_mb_iostatus(data));
	},
	addIOList: data => {
		dispatch(add_mb_iolist(data));
	},
	editIOList: data=>{
		dispatch(edit_mb_iolist(data));
	},
	delIOList: data => {
		dispatch(del_mb_iolist(data));
	},
	addAIO: data => {
		dispatch(add_mb_aio(data));
	},
	editAIO: data => {
		dispatch(edit_mb_aio(data));
	},
	delAIO: data => {
		dispatch(del_mb_aio(data));
	}
})

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