Proyectos de Subversion LeadersLinked - SPA

Rev

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

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