Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5912 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4531 stevensc 1
/* eslint-disable react/prop-types */
4534 stevensc 2
import React, { useEffect, useState } from 'react'
5912 stevensc 3
import { axios } from '../../../../../utils'
4
import { useDispatch } from 'react-redux'
5
import { setTimelineUrl } from '../../../../../redux/feed/feed.actions'
6
import FeedList from '../../../../../dashboard/templates/linkedin/Feed/FeedList'
4531 stevensc 7
import GroupInfo from '../../../../../group/view/templates/linkedin/components/GroupInfo'
5912 stevensc 8
import AboutCompany from '../components/AboutCompany'
9
import CompanyFollowers from '../components/CompanyFollowers'
10
import CompanyActions from '../components/CompanyActions'
6459 stevensc 11
import { setIntlLabels } from '../../../../../redux/intl/intl.action'
4531 stevensc 12
 
6459 stevensc 13
const View = ({ backendVars, labels }) => {
5912 stevensc 14
  const [authorizedLinks, setAuthorizedLinks] = useState(null)
15
  const [isFollower, setIsFollower] = useState(false)
16
  const dispatch = useDispatch()
4534 stevensc 17
 
5912 stevensc 18
  const fetchAuthorizedLinks = async () => {
19
    const { data: response } = await axios.get(
20
      `/company/view/${backendVars.companyId}`
21
    )
22
    if (response.success) {
23
      setAuthorizedLinks(response.data)
24
      if (response.data.link_unfollow) {
25
        setIsFollower(true)
26
      } else {
27
        setIsFollower(false)
28
      }
29
    }
30
  }
4534 stevensc 31
 
5912 stevensc 32
  useEffect(() => {
33
    dispatch(setTimelineUrl(backendVars.timeline))
6459 stevensc 34
    dispatch(setIntlLabels(labels))
5912 stevensc 35
    fetchAuthorizedLinks()
36
  }, [])
4534 stevensc 37
 
5912 stevensc 38
  return (
39
    <main className="w-100">
40
      <div className="container p-0 app__body layout__content">
41
        <div className="d-flex flex-column">
42
          <GroupInfo
43
            cover={backendVars.cover}
44
            image={backendVars.image}
45
            name={backendVars.companyName}
46
            overview={backendVars.overview}
47
            groupId={backendVars.companyId}
48
            totalMembers={backendVars.totalFollowers}
49
            groupType={backendVars.companySize}
50
            accessibility={backendVars.industry}
51
            type="company"
52
          />
53
        </div>
54
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
55
          <CompanyActions
56
            name={backendVars.companyName}
57
            image={backendVars.image}
58
            companyId={backendVars.companyId}
59
            cover={backendVars.cover}
60
            overview={backendVars.overview}
61
            refetch={() => fetchAuthorizedLinks()}
62
            actionLinks={authorizedLinks}
63
          />
64
          {!isFollower ? (
65
            <AboutCompany {...backendVars} />
66
          ) : (
67
            <FeedList
68
              image={`/storage/type/company/code/${backendVars.companyId}/${
69
                backendVars.image ? `filename/${backendVars.image}` : ''
70
              }`}
71
            />
72
          )}
73
        </div>
74
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
75
          <CompanyFollowers companyId={backendVars.companyId} />
76
          <AboutCompany {...backendVars} />
77
        </div>
78
      </div>
79
    </main>
80
  )
4531 stevensc 81
}
82
 
5912 stevensc 83
export default View