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