ListItemContainer.ts 868 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { connect } from 'react-redux';
  2. import { RootState, ClusterName, TopicName, Action } from 'redux/interfaces';
  3. import { withRouter, RouteComponentProps } from 'react-router-dom';
  4. import { ThunkDispatch } from 'redux-thunk';
  5. import { deleteTopic } from 'redux/actions';
  6. import ListItem from './ListItem';
  7. interface RouteProps {
  8. clusterName: ClusterName;
  9. }
  10. type OwnProps = RouteComponentProps<RouteProps>;
  11. const mapStateToProps = (
  12. state: RootState,
  13. {
  14. match: {
  15. params: { clusterName },
  16. },
  17. }: OwnProps
  18. ) => ({
  19. clusterName,
  20. });
  21. const mapDispatchToProps = (
  22. dispatch: ThunkDispatch<RootState, undefined, Action>
  23. ) => ({
  24. deleteTopic: (clusterName: ClusterName, topicName: TopicName) => {
  25. dispatch(deleteTopic(clusterName, topicName));
  26. },
  27. });
  28. export default withRouter(
  29. connect(mapStateToProps, mapDispatchToProps)(ListItem)
  30. );