Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 200 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5 stevensc 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'
6
 
7
import FeedList from '../../components/feed/linkedin/FeedList'
8
import GroupInfo from '../../components/widgets/linkedin/InfoWidget'
9
import AboutCompany from '../../components/company/AboutCompany'
10
import CompanyFollowers from '../../components/company/CompanyFollowers'
11
import CompanyActions from '../../components/company/CompanyActions'
12
 
13
import './styles/linkedin.scss'
14
 
15
const LinkedInCompany = () => {
16
  const [backendVars, setBackendVars] = useState(null)
17
  const [actionsUrls, setActionsUrls] = useState(null)
18
  const [isFollower, setIsFollower] = useState(false)
19
  const { uuid } = useParams()
20
  const dispatch = useDispatch()
21
 
22
  const getCompanyVars = () => {
23
    getBackendVars(`/company/view/${uuid}`)
24
      .then((vars) => {
25
        const actions = {}
26
 
27
        Object.entries(vars).forEach(([key, value]) => {
28
          if (!key.includes('link')) {
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)
39
      })
40
      .catch((err) => {
41
        console.log(`Error: ${err}`)
42
        throw new Error(err)
43
      })
44
  }
45
 
46
  useEffect(() => {
47
    getCompanyVars()
48
  }, [])
49
 
50
  return (
51
    <main className="w-100">
52
      <div className="container p-0 app__body layout__content">
53
        <div className="d-flex flex-column">
54
          <GroupInfo
55
            cover={backendVars?.cover}
56
            image={backendVars?.image}
57
            name={backendVars?.company_name}
58
            overview={backendVars?.overview}
59
            id={backendVars?.company_uuid}
60
            totalMembers={backendVars?.total_followers}
61
            groupType={backendVars?.company_size}
62
            accessibility={backendVars?.industry}
63
          />
64
        </div>
65
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
66
          <CompanyActions
67
            name={backendVars?.company_name}
68
            image={backendVars?.image}
69
            companyId={backendVars?.company_uuid}
70
            cover={backendVars?.cover}
71
            overview={backendVars?.overview}
72
            refetch={getCompanyVars}
73
            actionLinks={actionsUrls}
74
          />
75
          {!isFollower ? (
76
            <AboutCompany {...backendVars} />
77
          ) : (
78
            <FeedList
79
              image={`/storage/type/company/code/${backendVars?.companyId}/${
80
                backendVars?.image ? `filename/${backendVars?.image}` : ''
81
              }`}
82
            />
83
          )}
84
        </div>
85
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
86
          <CompanyFollowers companyId={uuid} />
87
          <AboutCompany {...backendVars} />
88
        </div>
89
      </div>
90
    </main>
91
  )
92
}
93
 
94
export default LinkedInCompany