| 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'
|
| 2875 |
stevensc |
25 |
import AppsWidget from '@components/dashboard/widgets/AppsWidget'
|
|
|
26 |
import OnRoomWidget from '@components/dashboard/widgets/OnRoomWidget'
|
| 2881 |
stevensc |
27 |
import MicrolearningWidget from '@components/dashboard/widgets/MicrolearningWidget'
|
| 2674 |
stevensc |
28 |
|
|
|
29 |
const DashboardPage = () => {
|
|
|
30 |
const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(
|
|
|
31 |
({ feed }) => feed
|
|
|
32 |
)
|
|
|
33 |
const dispatch = useDispatch()
|
|
|
34 |
|
|
|
35 |
const { id } = useParams()
|
|
|
36 |
const { data } = useFetch(id ? `/dashboard/feed/${id}` : '/dashboard')
|
|
|
37 |
|
|
|
38 |
const allFeeds = feeds.allIds.map((id) => feeds.byId[id])
|
|
|
39 |
|
|
|
40 |
const {
|
|
|
41 |
moodle_image,
|
|
|
42 |
moodle_name,
|
|
|
43 |
microlearning_appstore,
|
|
|
44 |
microlearning_playstore,
|
|
|
45 |
microlearning_name,
|
|
|
46 |
routeDailyPulse,
|
|
|
47 |
routeTimeline
|
|
|
48 |
} = data
|
|
|
49 |
|
|
|
50 |
const moodle = {
|
|
|
51 |
image: moodle_image,
|
|
|
52 |
name: moodle_name
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
const microlearning = {
|
|
|
56 |
playStore: microlearning_playstore,
|
|
|
57 |
appStore: microlearning_appstore,
|
|
|
58 |
name: microlearning_name
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
const onChangePageHandler = (currentPage) => {
|
|
|
62 |
dispatch(setCurrentPage(currentPage))
|
|
|
63 |
window.scrollTo(0, 0)
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
useEffect(() => {
|
|
|
67 |
dispatch(setTimelineUrl(routeTimeline))
|
|
|
68 |
}, [routeTimeline, id])
|
|
|
69 |
|
|
|
70 |
useEffect(() => {
|
|
|
71 |
dispatch(fetchFeeds(timelineUrl, currentPage))
|
|
|
72 |
}, [timelineUrl, currentPage])
|
|
|
73 |
|
|
|
74 |
return (
|
|
|
75 |
<>
|
| 2805 |
stevensc |
76 |
<AppGrid
|
|
|
77 |
renderSidebar={() => (
|
|
|
78 |
<>
|
|
|
79 |
<UserProfileCard user={data} />
|
| 2875 |
stevensc |
80 |
<OnRoomWidget moodle={moodle} />
|
| 2955 |
stevensc |
81 |
<MicrolearningWidget />
|
|
|
82 |
<AppsWidget microlearning={microlearning} />
|
| 2805 |
stevensc |
83 |
<GroupsWidget />
|
|
|
84 |
</>
|
|
|
85 |
)}
|
|
|
86 |
renderMain={() => (
|
|
|
87 |
<>
|
|
|
88 |
{data?.routeDailyPulse && (
|
| 2674 |
stevensc |
89 |
<div className='d-md-none'>
|
| 2805 |
stevensc |
90 |
<DailyPulse dailyPulseUrl={data?.routeDailyPulse} />
|
| 2674 |
stevensc |
91 |
</div>
|
| 2805 |
stevensc |
92 |
)}
|
|
|
93 |
<div className='d-md-none'>
|
|
|
94 |
<AppsWidget moodle={moodle} microlearning={microlearning} />
|
|
|
95 |
</div>
|
|
|
96 |
<FeedShare
|
|
|
97 |
image={data?.image}
|
|
|
98 |
feedType={feedTypes.DASHBOARD}
|
|
|
99 |
postUrl='/feed/add'
|
|
|
100 |
/>
|
|
|
101 |
{loading ? <Spinner /> : <FeedList feeds={allFeeds} />}
|
|
|
102 |
<PaginationComponent
|
|
|
103 |
pages={pages}
|
|
|
104 |
currentActivePage={currentPage}
|
|
|
105 |
onChangePage={onChangePageHandler}
|
|
|
106 |
/>
|
|
|
107 |
</>
|
|
|
108 |
)}
|
|
|
109 |
renderAside={() => (
|
|
|
110 |
<>
|
|
|
111 |
{routeDailyPulse && (
|
|
|
112 |
<div className='d-none d-md-block'>
|
|
|
113 |
<DailyPulse dailyPulseUrl={routeDailyPulse} />
|
|
|
114 |
</div>
|
|
|
115 |
)}
|
|
|
116 |
<PeopleYouMayKnow />
|
|
|
117 |
<HomeNews />
|
|
|
118 |
</>
|
|
|
119 |
)}
|
|
|
120 |
/>
|
| 2674 |
stevensc |
121 |
<ShareModal />
|
|
|
122 |
<ReportModal />
|
|
|
123 |
</>
|
|
|
124 |
)
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
export default DashboardPage
|