OverviewContainer.ts 955 B

123456789101112131415161718192021222324252627282930
  1. import { connect } from 'react-redux';
  2. import {
  3. fetchTopicDetails,
  4. } from 'redux/reducers/topics/thunks';
  5. import Overview from './Overview';
  6. import { RootState, TopicName, ClusterId } from 'lib/interfaces';
  7. import { getTopicByName, getIsTopicDetailsFetched } from 'redux/reducers/topics/selectors';
  8. import { withRouter, RouteComponentProps } from 'react-router-dom';
  9. interface RouteProps {
  10. clusterId: string;
  11. topicName: string;
  12. }
  13. interface OwnProps extends RouteComponentProps<RouteProps> { }
  14. const mapStateToProps = (state: RootState, { match: { params: { topicName, clusterId } } }: OwnProps) => ({
  15. clusterId,
  16. topicName,
  17. isFetched: getIsTopicDetailsFetched(state),
  18. ...getTopicByName(state, topicName),
  19. });
  20. const mapDispatchToProps = {
  21. fetchTopicDetails: (clusterId: ClusterId, topicName: TopicName) => fetchTopicDetails(clusterId, topicName),
  22. }
  23. export default withRouter(
  24. connect(mapStateToProps, mapDispatchToProps)(Overview)
  25. );