File size: 718 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import React from 'react';
import agent from '../../agent';
import { connect } from 'react-redux';
import { DELETE_COMMENT } from '../../constants/actionTypes';
const mapDispatchToProps = dispatch => ({
onClick: (payload, commentId) =>
dispatch({ type: DELETE_COMMENT, payload, commentId })
});
const DeleteButton = props => {
const del = () => {
const payload = agent.Comments.delete(props.slug, props.commentId);
props.onClick(payload, props.commentId);
};
if (props.show) {
return (
<span className="mod-options">
<i className="ion-trash-a" onClick={del}></i>
</span>
);
}
return null;
};
export default connect(() => ({}), mapDispatchToProps)(DeleteButton);
|