Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 856 Rev 1688
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { useDispatch } from 'react-redux'
-
 
3
import { setTimelineUrl } from '../../redux/feed/feed.actions'
-
 
4
import { getBackendVars } from '../../services/backendVars'
-
 
5
import { useParams } from 'react-router-dom'
2
import { useParams } from 'react-router-dom'
-
 
3
import { useDispatch, useSelector } from 'react-redux'
Línea -... Línea 4...
-
 
4
 
-
 
5
import {
-
 
6
  fetchFeeds,
-
 
7
  setCurrentPage,
-
 
8
  setTimelineUrl
6
 
9
} from '../../redux/feed/feed.actions'
-
 
10
import { getBackendVars } from '../../services/backendVars'
7
import FeedList from '../../components/dashboard/linkedin/feed-list/FeedList'
11
 
8
import GroupInfo from '../../components/widgets/linkedin/InfoWidget'
12
import PaginationComponent from '@app/components/UI/PaginationComponent'
9
import AboutCompany from '../../components/company/AboutCompany'
-
 
10
import CompanyFollowers from '../../components/company/CompanyFollowers'
13
import AboutCompany from '../../components/company/AboutCompany'
-
 
14
import CompanyActions from '../../components/company/CompanyActions'
-
 
15
import CompanyFollowers from '../../components/company/CompanyFollowers'
-
 
16
import FeedList from '../../components/dashboard/linkedin/feed-list/FeedList'
Línea 11... Línea 17...
11
import CompanyActions from '../../components/company/CompanyActions'
17
import GroupInfo from '../../components/widgets/linkedin/InfoWidget'
Línea 12... Línea 18...
12
 
18
 
13
import './styles/linkedin.scss'
19
import './styles/linkedin.scss'
14
 
20
 
15
const LinkedInCompany = () => {
21
const LinkedInCompany = () => {
-
 
22
  const [backendVars, setBackendVars] = useState(null)
-
 
23
  const [actionsUrls, setActionsUrls] = useState(null)
-
 
24
  const [isFollower, setIsFollower] = useState(false)
-
 
25
  const { feeds, timelineUrl, currentPage, loading, pages } = useSelector(
16
  const [backendVars, setBackendVars] = useState(null)
26
    ({ feed }) => feed
17
  const [actionsUrls, setActionsUrls] = useState(null)
27
  )
Línea 18... Línea 28...
18
  const [isFollower, setIsFollower] = useState(false)
28
  const allFeeds = feeds.allIds.map((id) => feeds.byId[id])
19
  const { uuid } = useParams()
29
  const { uuid } = useParams()
20
  const dispatch = useDispatch()
-
 
21
 
30
  const dispatch = useDispatch()
22
  const getCompanyVars = () => {
31
 
23
    getBackendVars(`/company/view/${uuid}`)
32
  const getCompanyVars = () => {
24
      .then((vars) => {
33
    getBackendVars(`/company/view/${uuid}`).then((vars) => {
25
        const actions = {}
-
 
26
 
-
 
27
        Object.entries(vars).forEach(([key, value]) => {
-
 
28
          if (!key.includes('link')) {
34
      const actions = {}
29
            return
-
 
30
          }
-
 
31
 
-
 
32
          actions[key] = value
-
 
33
        })
-
 
34
 
-
 
35
        setActionsUrls(actions)
-
 
36
        dispatch(setTimelineUrl(vars.link_timeline))
-
 
37
        setIsFollower(!!vars.link_unfollow)
-
 
38
        setBackendVars(vars)
35
 
-
 
36
      Object.entries(vars).forEach(([key, value]) => {
-
 
37
        if (!key.includes('link')) return
-
 
38
        actions[key] = value
-
 
39
      })
-
 
40
 
-
 
41
      setActionsUrls(actions)
-
 
42
      dispatch(setTimelineUrl(vars.link_timeline))
-
 
43
      setIsFollower(!!vars.link_unfollow)
-
 
44
      setBackendVars(vars)
-
 
45
    })
-
 
46
  }
39
      })
47
 
Línea 40... Línea 48...
40
      .catch((err) => {
48
  const onChangePageHandler = (currentPage) => {
-
 
49
    dispatch(setCurrentPage(currentPage))
-
 
50
    window.scrollTo(0, 0)
-
 
51
  }
-
 
52
 
41
        console.log(`Error: ${err}`)
53
  useEffect(() => {
42
      })
54
    dispatch(fetchFeeds(timelineUrl, currentPage))
Línea 43... Línea 55...
43
  }
55
  }, [timelineUrl, currentPage])
44
 
56
 
Línea 59... Línea 71...
59
            totalMembers={backendVars?.total_followers}
71
            totalMembers={backendVars?.total_followers}
60
            groupType={backendVars?.company_size}
72
            groupType={backendVars?.company_size}
61
            accessibility={backendVars?.industry}
73
            accessibility={backendVars?.industry}
62
          />
74
          />
63
        </div>
75
        </div>
-
 
76
 
64
        <div className='d-flex flex-column' style={{ gap: '.5rem' }}>
77
        <div className='d-flex flex-column' style={{ gap: '.5rem' }}>
65
          <CompanyActions
78
          <CompanyActions
66
            name={backendVars?.company_name}
79
            name={backendVars?.company_name}
67
            image={backendVars?.image}
80
            image={backendVars?.image}
68
            companyId={backendVars?.company_uuid}
81
            companyId={backendVars?.company_uuid}
Línea 72... Línea 85...
72
            actionLinks={actionsUrls}
85
            actionLinks={actionsUrls}
73
          />
86
          />
74
          {!isFollower ? (
87
          {!isFollower ? (
75
            <AboutCompany {...backendVars} />
88
            <AboutCompany {...backendVars} />
76
          ) : (
89
          ) : (
-
 
90
            <>
77
            <FeedList
91
              <FeedList
-
 
92
                feeds={allFeeds}
-
 
93
                loading={loading}
78
              image={`/storage/type/company/code/${backendVars?.companyId}/${
94
                image={`/storage/type/company/code/${backendVars?.companyId}/${
79
                backendVars?.image ? `filename/${backendVars?.image}` : ''
95
                  backendVars?.image ? `filename/${backendVars?.image}` : ''
80
              }`}
96
                }`}
-
 
97
              />
-
 
98
              <PaginationComponent
-
 
99
                pages={pages}
-
 
100
                currentActivePage={currentPage}
-
 
101
                onChangePage={onChangePageHandler}
-
 
102
                isRow
-
 
103
              />
81
            />
104
            </>
82
          )}
105
          )}
83
        </div>
106
        </div>
-
 
107
 
84
        <div className='d-flex flex-column' style={{ gap: '.5rem' }}>
108
        <div className='d-flex flex-column' style={{ gap: '.5rem' }}>
85
          <CompanyFollowers companyId={uuid} />
109
          <CompanyFollowers companyId={uuid} />
86
          <AboutCompany {...backendVars} />
110
          <AboutCompany {...backendVars} />
87
        </div>
111
        </div>
88
      </div>
112
      </div>