6830 |
stevensc |
1 |
import React, { useEffect, useState } from 'react'
|
|
|
2 |
import { axios } from '../../utils'
|
|
|
3 |
import { useDispatch } from 'react-redux'
|
|
|
4 |
import { setTimelineUrl } from '../../redux/feed/feed.actions'
|
|
|
5 |
import { getBackendVars } from '../../services/backendVars'
|
|
|
6 |
import { useParams } from 'react-router-dom'
|
|
|
7 |
|
|
|
8 |
import FeedList from '../../components/feed/linkedin/FeedList'
|
|
|
9 |
import GroupInfo from '../../components/group/GroupInfo'
|
|
|
10 |
import AboutCompany from '../../components/company/AboutCompany'
|
|
|
11 |
import CompanyFollowers from '../../components/company/CompanyFollowers'
|
|
|
12 |
import CompanyActions from '../../components/company/CompanyActions'
|
|
|
13 |
|
6834 |
stevensc |
14 |
import './styles/linkedin.scss'
|
|
|
15 |
|
6830 |
stevensc |
16 |
const LinkedInCompany = () => {
|
|
|
17 |
const [backendVars, setBackendVars] = useState(null)
|
|
|
18 |
const [authorizedLinks, setAuthorizedLinks] = useState(null)
|
|
|
19 |
const [isFollower, setIsFollower] = useState(false)
|
|
|
20 |
const { uuid } = useParams()
|
|
|
21 |
const dispatch = useDispatch()
|
|
|
22 |
|
|
|
23 |
const fetchAuthorizedLinks = async () => {
|
|
|
24 |
const { data: response } = await axios.get(`/company/view/${uuid}`)
|
|
|
25 |
const { data, success } = response
|
|
|
26 |
|
|
|
27 |
if (success) {
|
|
|
28 |
setAuthorizedLinks(data)
|
|
|
29 |
setIsFollower(!!data.link_unfollow)
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
useEffect(() => {
|
|
|
34 |
fetchAuthorizedLinks()
|
|
|
35 |
}, [])
|
|
|
36 |
|
|
|
37 |
useEffect(() => {
|
|
|
38 |
getBackendVars(`/company/view/${uuid}`)
|
|
|
39 |
.then((vars) => {
|
|
|
40 |
console.log(vars)
|
|
|
41 |
setBackendVars(vars)
|
|
|
42 |
})
|
|
|
43 |
.catch((err) => {
|
|
|
44 |
console.log(`Error: ${err}`)
|
|
|
45 |
throw new Error(err)
|
|
|
46 |
})
|
|
|
47 |
}, [])
|
|
|
48 |
|
|
|
49 |
return (
|
|
|
50 |
<main className="w-100">
|
|
|
51 |
<div className="container p-0 app__body layout__content">
|
|
|
52 |
<div className="d-flex flex-column">
|
|
|
53 |
<GroupInfo
|
|
|
54 |
cover={backendVars?.cover}
|
|
|
55 |
image={backendVars?.image}
|
|
|
56 |
name={backendVars?.companyName}
|
|
|
57 |
overview={backendVars?.overview}
|
|
|
58 |
groupId={backendVars?.companyId}
|
|
|
59 |
totalMembers={backendVars?.totalFollowers}
|
|
|
60 |
groupType={backendVars?.companySize}
|
|
|
61 |
accessibility={backendVars?.industry}
|
|
|
62 |
type="company"
|
|
|
63 |
/>
|
|
|
64 |
</div>
|
|
|
65 |
<div className="d-flex flex-column" style={{ gap: '.5rem' }}>
|
|
|
66 |
<CompanyActions
|
|
|
67 |
name={backendVars?.companyName}
|
|
|
68 |
image={backendVars?.image}
|
|
|
69 |
companyId={backendVars?.companyId}
|
|
|
70 |
cover={backendVars?.cover}
|
|
|
71 |
overview={backendVars?.overview}
|
|
|
72 |
refetch={() => fetchAuthorizedLinks()}
|
|
|
73 |
actionLinks={authorizedLinks}
|
|
|
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
|