Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7467 | Rev 7794 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7459 stevensc 1
import React, { useEffect } from "react";
7205 stevensc 2
import FeedTemplate from "./FeedTemplate";
7458 stevensc 3
import { fetchFeeds, setCurrentPage } from '../../redux/feed/feed.actions'
4
import { useDispatch, useSelector } from "react-redux";
5
import PaginationComponent from "../../shared/PaginationComponent";
7786 stevensc 6
import Spinner from "../../shared/Spinner";
7
import NotificationAlert from "../../shared/notification/NotificationAlert";
7161 stevensc 8
 
7458 stevensc 9
const FeedSection = React.memo(() => {
7205 stevensc 10
 
7458 stevensc 11
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
7463 stevensc 12
 
7458 stevensc 13
  const dispatch = useDispatch()
7205 stevensc 14
 
7458 stevensc 15
  useEffect(() => {
16
    dispatch(fetchFeeds(timelineUrl, currentPage))
7467 stevensc 17
    console.log(timelineUrl)
18
  }, [timelineUrl]);
7458 stevensc 19
 
20
 
21
  const onChangePageHandler = (currentPage) => {
22
    dispatch(setCurrentPage(currentPage))
23
    dispatch(fetchFeeds(timelineUrl, currentPage))
24
    window.scrollTo(0, 0);
25
  };
26
 
7235 stevensc 27
  if (loading) {
7786 stevensc 28
    return <Spinner />
7221 stevensc 29
  }
30
 
7235 stevensc 31
 
7154 stevensc 32
  return (
7232 stevensc 33
    <>
34
      {
7458 stevensc 35
        allFeeds.map((feed) =>
7232 stevensc 36
          <FeedTemplate
37
            feed={feed}
38
            key={feed.feed_unique}
39
          />
40
        )
41
      }
7458 stevensc 42
      <PaginationComponent
43
        onChangePage={onChangePageHandler}
44
        pages={pages}
45
        isRow
46
        currentActivePage={currentPage}
47
      />
7786 stevensc 48
      <NotificationAlert />
7232 stevensc 49
    </>
7205 stevensc 50
  );
7235 stevensc 51
});
7205 stevensc 52
 
7154 stevensc 53
export default FeedSection