Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6834 | Rev 6837 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6830 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/group/GroupInfo'
9
import AboutCompany from '../../components/company/AboutCompany'
10
import CompanyFollowers from '../../components/company/CompanyFollowers'
11
import CompanyActions from '../../components/company/CompanyActions'
12
 
6834 stevensc 13
import './styles/linkedin.scss'
14
 
6830 stevensc 15
const LinkedInCompany = () => {
16
  const [backendVars, setBackendVars] = useState(null)
6835 stevensc 17
  const [actionsUrls, setActionsUrls] = useState(null)
6830 stevensc 18
  const [isFollower, setIsFollower] = useState(false)
19
  const { uuid } = useParams()
20
 
6835 stevensc 21
  const getCompanyVars = () => {
22
    getBackendVars(`/company/view/${uuid}`)
23
      .then((vars) => {
24
        const actions = {}
6830 stevensc 25
 
6835 stevensc 26
        Object.entries(vars).forEach(([key, value]) => {
27
          if (!key.includes('link')) {
28
            return
29
          }
6830 stevensc 30
 
6835 stevensc 31
          actions[key] = value
32
        })
6830 stevensc 33
 
6835 stevensc 34
        setActionsUrls(actions)
35
 
36
        setIsFollower(!!vars.link_unfollow)
6830 stevensc 37
        setBackendVars(vars)
38
      })
39
      .catch((err) => {
40
        console.log(`Error: ${err}`)
41
        throw new Error(err)
42
      })
6835 stevensc 43
  }
44
 
45
  useEffect(() => {
46
    getCompanyVars()
6830 stevensc 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
6835 stevensc 67
            name={backendVars?.company_name}
6830 stevensc 68
            image={backendVars?.image}
6835 stevensc 69
            companyId={backendVars?.company_uuid}
6830 stevensc 70
            cover={backendVars?.cover}
71
            overview={backendVars?.overview}
6835 stevensc 72
            refetch={getCompanyVars}
73
            actionLinks={actionsUrls}
6830 stevensc 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