Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4540 | Ir a la última revisión | | 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'
4531 stevensc 11
 
12
const View = ({ backendVars }) => {
5912 stevensc 13
  const [authorizedLinks, setAuthorizedLinks] = useState(null)
14
  const [isFollower, setIsFollower] = useState(false)
15
  const dispatch = useDispatch()
4534 stevensc 16
 
5912 stevensc 17
  const fetchAuthorizedLinks = async () => {
18
    const { data: response } = await axios.get(
19
      `/company/view/${backendVars.companyId}`
20
    )
21
    if (response.success) {
22
      setAuthorizedLinks(response.data)
23
      if (response.data.link_unfollow) {
24
        setIsFollower(true)
25
      } else {
26
        setIsFollower(false)
27
      }
28
    }
29
  }
4534 stevensc 30
 
5912 stevensc 31
  useEffect(() => {
32
    dispatch(setTimelineUrl(backendVars.timeline))
33
    fetchAuthorizedLinks()
34
  }, [])
4534 stevensc 35
 
5912 stevensc 36
  return (
37
    <main className="w-100">
38
      <div className="container p-0 app__body layout__content">
39
        <div className="d-flex flex-column">
40
          <GroupInfo
41
            cover={backendVars.cover}
42
            image={backendVars.image}
43
            name={backendVars.companyName}
44
            overview={backendVars.overview}
45
            groupId={backendVars.companyId}
46
            totalMembers={backendVars.totalFollowers}
47
            groupType={backendVars.companySize}
48
            accessibility={backendVars.industry}
49
            type="company"
50
          />
51
        </div>
52
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
53
          <CompanyActions
54
            name={backendVars.companyName}
55
            image={backendVars.image}
56
            companyId={backendVars.companyId}
57
            cover={backendVars.cover}
58
            overview={backendVars.overview}
59
            refetch={() => fetchAuthorizedLinks()}
60
            actionLinks={authorizedLinks}
61
          />
62
          {!isFollower ? (
63
            <AboutCompany {...backendVars} />
64
          ) : (
65
            <FeedList
66
              image={`/storage/type/company/code/${backendVars.companyId}/${
67
                backendVars.image ? `filename/${backendVars.image}` : ''
68
              }`}
69
            />
70
          )}
71
        </div>
72
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
73
          <CompanyFollowers companyId={backendVars.companyId} />
74
          <AboutCompany {...backendVars} />
75
        </div>
76
      </div>
77
    </main>
78
  )
4531 stevensc 79
}
80
 
5912 stevensc 81
export default View