Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7794 | Rev 14867 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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