Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3688 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3688 Rev 3719
Línea 1... Línea 1...
1
import React, { useEffect } from 'react';
1
import React, { useEffect } from 'react';
2
import { useParams } from 'react-router-dom';
2
import { useParams } from 'react-router-dom';
3
import { useDispatch, useSelector } from 'react-redux';
3
import { useDispatch, useSelector } from 'react-redux';
4
 
4
 
5
import { useFetch } from '@hooks';
5
import { useFetch } from '@hooks';
6
import { feedTypes } from '@store/feed/feed.types';
6
import { feedTypes } from '@store/feed/feed.types';
7
import { fetchFeeds, setCurrentPage, setTimelineUrl } from '@store/feed/feed.actions';
7
import { fetchFeeds, setCurrentPage, setTimelineUrl } from '@store/feed/feed.actions';
8
import { Pagination, Spinner } from '@shared/components';
8
import { Pagination, Spinner } from '@shared/components';
9
import AppGrid from '@components/UI/layout/AppGrid';
9
import AppGrid from '@components/UI/layout/AppGrid';
10
import GroupWidget from '@components/widgets/linkedin/group-widget';
10
import GroupWidget from '@components/widgets/linkedin/group-widget';
11
import GroupActions from '@groups/components/sections-cards/group-actions/GroupActions';
11
import GroupActions from '@groups/components/sections-cards/group-actions/GroupActions';
12
import ShareComponent from '@components/dashboard/linkedin/share/ShareComponent';
12
import ShareComponent from '@components/dashboard/linkedin/share/ShareComponent';
13
import FeedList from '@components/dashboard/linkedin/feed-list/FeedList';
13
import FeedList from '@components/dashboard/linkedin/feed-list/FeedList';
14
import Members from '@groups/components/sections-cards/members/Members';
14
import Members from '@groups/components/sections-cards/members/Members';
15
import ShareModal from '@components/modals/ShareModal';
-
 
16
import AboutGroup from '@groups/components/AboutGroup';
15
import AboutGroup from '@groups/components/AboutGroup';
17
 
16
 
18
const GroupPage = () => {
17
const GroupPage = () => {
19
  const { uuid } = useParams();
18
  const { uuid } = useParams();
20
  const dispatch = useDispatch();
19
  const dispatch = useDispatch();
21
  const { data, isLoading, refetch } = useFetch(`/group/view/${uuid}`);
20
  const { data, isLoading, refetch } = useFetch(`/group/view/${uuid}`);
22
 
21
 
23
  const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(({ feed }) => feed);
22
  const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(({ feed }) => feed);
24
  const allFeeds = feeds.allIds.map((id) => feeds.byId[id]);
23
  const allFeeds = feeds.allIds.map((id) => feeds.byId[id]);
25
 
24
 
26
  const onChangePageHandler = (currentPage) => {
25
  const onChangePageHandler = (currentPage) => {
27
    dispatch(setCurrentPage(currentPage));
26
    dispatch(setCurrentPage(currentPage));
28
    window.scrollTo(0, 0);
27
    window.scrollTo(0, 0);
29
  };
28
  };
30
 
29
 
31
  useEffect(() => {
30
  useEffect(() => {
32
    dispatch(fetchFeeds(timelineUrl, currentPage));
31
    dispatch(fetchFeeds(timelineUrl, currentPage));
33
  }, [timelineUrl, currentPage]);
32
  }, [timelineUrl, currentPage]);
34
 
33
 
35
  useEffect(() => {
34
  useEffect(() => {
36
    dispatch(setTimelineUrl(`/feed/timeline/${data.group_uuid}/group`));
35
    dispatch(setTimelineUrl(`/feed/timeline/${data.group_uuid}/group`));
37
  }, [data]);
36
  }, [data]);
38
 
37
 
39
  if (isLoading) {
38
  if (isLoading) {
40
    return <Spinner />;
39
    return <Spinner />;
41
  }
40
  }
42
 
41
 
43
  return (
42
  return (
44
    <>
-
 
45
      <AppGrid
43
    <AppGrid
46
        renderSidebar={() => <GroupWidget group={data} />}
44
      renderSidebar={() => <GroupWidget group={data} />}
47
        renderMain={() => (
45
      renderMain={() => (
48
          <>
46
        <>
49
            <GroupActions {...data} refetch={refetch} />
47
          <GroupActions {...data} refetch={refetch} />
50
            {data.without_feeds ? (
48
          {data.without_feeds ? (
51
              <AboutGroup {...data} />
49
            <AboutGroup {...data} />
52
            ) : (
50
          ) : (
53
              <>
51
            <>
54
                <ShareComponent
52
              <ShareComponent
55
                  feedType={feedTypes.GROUP}
53
                feedType={feedTypes.GROUP}
56
                  postUrl={`/feed/add/group/${uuid}`}
54
                postUrl={`/feed/add/group/${uuid}`}
57
                  image={data?.image}
55
                image={data?.image}
58
                />
56
              />
59
                <FeedList feeds={allFeeds} loading={loading} />
57
              <FeedList feeds={allFeeds} loading={loading} />
60
                <Pagination pages={pages} page={currentPage} onChange={onChangePageHandler} />
58
              <Pagination pages={pages} page={currentPage} onChange={onChangePageHandler} />
61
              </>
59
            </>
62
            )}
60
          )}
63
          </>
61
        </>
64
        )}
62
      )}
65
        renderAside={() => (
63
      renderAside={() => (
66
          <>
64
        <>
67
            <Members id={data.group_uuid} />
65
          <Members id={data.group_uuid} />
68
            {!data.without_feeds && <AboutGroup {...data} />}
66
          {!data.without_feeds && <AboutGroup {...data} />}
69
          </>
67
        </>
70
        )}
68
      )}
71
      />
-
 
72
      <ShareModal timelineUrl={timelineUrl} currentPage={currentPage} />
-
 
73
    </>
69
    />
74
  );
70
  );
75
};
71
};
76
 
72
 
77
export default GroupPage;
73
export default GroupPage;