import {connect} from 'react-redux';
import {add_dialog_msg, toggle_loading, get_link_list, clear_link, add_link, del_link, sw_link_active} from '../../actions';
import ActionLinkPage from '../../components/AdminPage/ActionLink';

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

const mapDispatchToProps = (dispatch, ownProps) => ({
	showDialog: (msg) => {
		dispatch(add_dialog_msg(msg));
	},
	toggleLoading: (active = false) => {
		dispatch(toggle_loading(active));
	},
	getList: () => {
		dispatch(get_link_list());
	},
	clearList: () => {
		dispatch(clear_link());
	},
	delLink: (data) => {
		dispatch(del_link(data));
	},
	addLink: (data) => {
		dispatch(add_link(data));
	},
	swLink: (data) => {
		dispatch(sw_link_active(data));
	}
})

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