CollectionPage.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import { Divider } from 'antd';
  2. import Title from 'antd/lib/typography/Title';
  3. import React, { useEffect } from 'react';
  4. import { connect } from 'react-redux';
  5. import { actionFullMyCollectionLoad, actionRemovePostsFeedAC } from '../actions';
  6. import { CPosts } from '../components/main/Posts';
  7. import { Container } from './Content';
  8. import { CPreloader } from './Preloader';
  9. export const CollectionPage = ({ posts, onLoadPosts, postsRemove }) => {
  10. useEffect(() => {
  11. onLoadPosts()
  12. return () => {
  13. postsRemove()
  14. }
  15. }, [])
  16. return (
  17. <Container>
  18. <CPreloader promiseName='onLoadMyCollections' />
  19. <Divider><Title level={1}>Collections</Title></Divider>
  20. {posts.lenght
  21. ? <CPosts />
  22. : <Title level={4}>
  23. The collection is empty. Add posts to your collection
  24. </Title>}
  25. </Container>
  26. )
  27. }
  28. export const CCollectionPage = connect(state => ({ posts: state?.postsFeed?.posts || [] }), { onLoadPosts: actionFullMyCollectionLoad, postsRemove: actionRemovePostsFeedAC })(CollectionPage)