Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 5 | Rev 3105 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5 Rev 3104
Línea 1... Línea 1...
1
import React, { lazy } from 'react'
1
import React, { useEffect } from 'react'
2
import { useSelector } from 'react-redux'
2
import { useDispatch, useSelector } from 'react-redux'
-
 
3
import { useParams } from 'react-router-dom'
Línea -... Línea 4...
-
 
4
 
-
 
5
import { useFetch } from '@hooks'
-
 
6
import {
-
 
7
  fetchFeeds,
-
 
8
  setCurrentPage,
3
 
9
  setTimelineUrl
Línea -... Línea 10...
-
 
10
} from '@store/feed/feed.actions'
4
const LinkedIn = lazy(() => import('../../layouts/company/LinkedInCompany'))
11
 
-
 
12
import AppGrid from '@components/UI/layout/AppGrid'
-
 
13
import Spinner from '@components/UI/Spinner'
-
 
14
import Pagination from '@components/common/Pagination'
-
 
15
import GroupWidget from '@components/widgets/linkedin/group-widget'
-
 
16
import FeedList from '@components/dashboard/linkedin/feed-list/FeedList'
5
 
17
import CompanyFollowers from '@components/company/CompanyFollowers'
Línea -... Línea 18...
-
 
18
import CompanyWidget from '@components/company/company-widget'
-
 
19
import AboutCompany from '@components/company/about-company'
6
const CompanyViewPage = () => {
20
 
-
 
21
export default function LinkedInCompany() {
7
  const { theme_id } = useSelector(({ auth }) => auth)
22
  const { uuid } = useParams()
-
 
23
  const dispatch = useDispatch()
-
 
24
  const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(
-
 
25
    ({ feed }) => feed
-
 
26
  )
-
 
27
 
-
 
28
  const { data, isLoading, refetch } = useFetch(`/company/view/${uuid}`)
-
 
29
 
-
 
30
  const isFollower = !!data.link_unfollow
-
 
31
  const allFeeds = feeds.allIds.map((id) => feeds.byId[id])
8
 
32
 
9
  switch (theme_id) {
33
  const onChangePageHandler = (currentPage) => {
10
    default:
-
 
Línea -... Línea 34...
-
 
34
    dispatch(setCurrentPage(currentPage))
-
 
35
    window.scrollTo(0, 0)
-
 
36
  }
-
 
37
 
-
 
38
  useEffect(() => {
-
 
39
    dispatch(fetchFeeds(timelineUrl, currentPage))
-
 
40
  }, [timelineUrl, currentPage])
-
 
41
 
-
 
42
  useEffect(() => {
-
 
43
    dispatch(setTimelineUrl(data.link_timeline))
-
 
44
  }, [data])
-
 
45
 
-
 
46
  if (isLoading) {
-
 
47
    return <Spinner />
-
 
48
  }
-
 
49
 
-
 
50
  return (
-
 
51
    <AppGrid
-
 
52
      renderSidebar={() => <GroupWidget />}
-
 
53
      renderMain={() => (
-
 
54
        <>
-
 
55
          <CompanyWidget company={data} refetch={refetch} />
-
 
56
          {!isFollower && <AboutCompany company={data} />}
11
      return <LinkedIn />
57
          {isFollower && !loading && (
-
 
58
            <>
-
 
59
              <FeedList feeds={allFeeds} />
-
 
60
              <Pagination
-
 
61
                pages={pages}
-
 
62
                page={currentPage}
-
 
63
                onChange={onChangePageHandler}
-
 
64
              />
-
 
65
            </>
-
 
66
          )}
-
 
67
        </>
-
 
68
      )}
-
 
69
      renderAside={() => (
-
 
70
        <>
-
 
71
          <CompanyFollowers companyId={uuid} />
-
 
72
          <AboutCompany company={data} />
-
 
73
        </>