text: /**
   *
   * AllPosts
   *
   */
  
  import React, { memo, useEffect } from 'react';
  import PropTypes from 'prop-types';
  import { connect } from 'react-redux';
  import { Helmet } from 'react-helmet';
  import { createStructuredSelector } from 'reselect';
  import { compose } from 'redux';
  
  import { Grid, makeStyles } from '@material-ui/core';
  import { useInjectSaga } from '../../utils/injectSaga';
  import { useInjectReducer } from '../../utils/injectReducer';
  import reducer from './reducer';
  import saga from './saga';
  import PostsList from './components/PostsList';
  import PostsDialog from './components/PostsDialog';
  import * as Actions from './actions';
  
  const useStyles = makeStyles(theme => ({
    textField: {
      marginLeft: theme.spacing(1),
      marginRight: theme.spacing(1),
    },
  }));
  
  export function AllPosts(props) {
    const { dispatchPostsAction } = props;
    const classes = useStyles();
    useInjectReducer({ key: 'allPosts', reducer });
    useInjectSaga({ key: 'allPosts', saga });
  
    useEffect(() => {
      dispatchPostsAction();
    }, []);
  
    return (
      <React.Fragment>
        <Helmet>
          <title>AllPosts</title>
          <meta name="description" content="Description of AllPosts" />
        </Helmet>
  
        <Grid container spacing={3}>
          <Grid item xs={12} sm={12} md={12}>
            {/* all post component */}
            <PostsList />
  
            {/* To create new post dialog */}
            <PostsDialog />
          </Grid>
        </Grid>
      </React.Fragment>
    );
  }
  
  AllPosts.propTypes = {
    dispatchPostsAction: PropTypes.oneOfType([PropTypes.func, PropTypes.array]),
  };
  
  const mapStateToProps = createStructuredSelector({});
  
  function mapDispatchToProps(dispatch) {
    return {
      dispatchPostsAction: () => dispatch(Actions.allPosts()),
      dispatch,
    };
  }
  
  const withConnect = connect(
    mapStateToProps,
    mapDispatchToProps,
  );
  
  export default compose(
    withConnect,
    memo,
  )(AllPosts);
  