Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
2674 stevensc 1
import React, { useEffect } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
3
import { useParams } from 'react-router-dom'
4
 
2780 stevensc 5
import { useFetch } from '@hooks'
2674 stevensc 6
import {
7
  fetchFeeds,
8
  setCurrentPage,
9
  setTimelineUrl
10
} from '@app/redux/feed/feed.actions'
11
import { feedTypes } from '@app/redux/feed/feed.types'
12
 
13
import PaginationComponent from '@app/components/UI/PaginationComponent'
14
import Spinner from '@app/components/UI/Spinner'
15
import AppGrid from '@app/components/UI/layout/AppGrid'
16
import GroupsWidget from '@app/components/dashboard/linkedin/Groups'
2678 stevensc 17
import UserProfileCard from '@app/components/dashboard/linkedin/user-profile-card'
2674 stevensc 18
import FeedList from '@app/components/dashboard/linkedin/feed-list/FeedList'
19
import FeedShare from '@app/components/dashboard/linkedin/share/ShareComponent'
20
import ReportModal from '@app/components/modals/ReportModal'
21
import ShareModal from '@app/components/modals/ShareModal'
22
import DailyPulse from '@app/components/widgets/default/DailyPulse'
23
import HomeNews from '@app/components/widgets/default/HomeNews'
24
import PeopleYouMayKnow from '@app/components/widgets/default/PeopleYouMayKnow'
25
import AppsWidget from '@app/components/widgets/default/SocialNetworks'
26
 
27
const DashboardPage = () => {
28
  const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(
29
    ({ feed }) => feed
30
  )
31
  const dispatch = useDispatch()
32
 
33
  const { id } = useParams()
34
  const { data } = useFetch(id ? `/dashboard/feed/${id}` : '/dashboard')
35
 
36
  const allFeeds = feeds.allIds.map((id) => feeds.byId[id])
37
 
38
  const {
39
    moodle_image,
40
    moodle_name,
41
    microlearning_appstore,
42
    microlearning_playstore,
43
    microlearning_name,
44
    routeDailyPulse,
45
    routeTimeline
46
  } = data
47
 
48
  const moodle = {
49
    image: moodle_image,
50
    name: moodle_name
51
  }
52
 
53
  const microlearning = {
54
    playStore: microlearning_playstore,
55
    appStore: microlearning_appstore,
56
    name: microlearning_name
57
  }
58
 
59
  const onChangePageHandler = (currentPage) => {
60
    dispatch(setCurrentPage(currentPage))
61
    window.scrollTo(0, 0)
62
  }
63
 
64
  useEffect(() => {
65
    dispatch(setTimelineUrl(routeTimeline))
66
  }, [routeTimeline, id])
67
 
68
  useEffect(() => {
69
    dispatch(fetchFeeds(timelineUrl, currentPage))
70
  }, [timelineUrl, currentPage])
71
 
72
  return (
73
    <>
2805 stevensc 74
      <AppGrid
75
        renderSidebar={() => (
76
          <>
77
            <UserProfileCard user={data} />
78
            <GroupsWidget />
79
            <AppsWidget moodle={moodle} microlearning={microlearning} />
80
          </>
81
        )}
82
        renderMain={() => (
83
          <>
84
            {data?.routeDailyPulse && (
2674 stevensc 85
              <div className='d-md-none'>
2805 stevensc 86
                <DailyPulse dailyPulseUrl={data?.routeDailyPulse} />
2674 stevensc 87
              </div>
2805 stevensc 88
            )}
89
            <div className='d-md-none'>
90
              <AppsWidget moodle={moodle} microlearning={microlearning} />
91
            </div>
92
            <FeedShare
93
              image={data?.image}
94
              feedType={feedTypes.DASHBOARD}
95
              postUrl='/feed/add'
96
            />
97
            {loading ? <Spinner /> : <FeedList feeds={allFeeds} />}
98
            <PaginationComponent
99
              pages={pages}
100
              currentActivePage={currentPage}
101
              onChangePage={onChangePageHandler}
102
            />
103
          </>
104
        )}
105
        renderAside={() => (
106
          <>
107
            {routeDailyPulse && (
108
              <div className='d-none d-md-block'>
109
                <DailyPulse dailyPulseUrl={routeDailyPulse} />
110
              </div>
111
            )}
112
            <PeopleYouMayKnow />
113
            <HomeNews />
114
          </>
115
        )}
116
      />
2674 stevensc 117
      <ShareModal />
118
      <ReportModal />
119
    </>
120
  )
121
}
122
 
123
export default DashboardPage