Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
6862 stevensc 1
import React, { useEffect, useState } from 'react'
2
import { useParams } from 'react-router-dom'
3
import { useDispatch } from 'react-redux'
4
import { getBackendVars } from '../../services/backendVars'
5
import { setTimelineUrl } from '../../redux/feed/feed.actions'
6
import { addNotification } from '../../redux/notification/notification.actions'
7
 
8
import Members from '../../components/group/Members'
9
import FeedList from '../../components/feed/linkedin/FeedList'
10
import FeedShare from '../../components/feed/linkedin/FeedShare'
11
import InfoWidget from '../../components/widgets/linkedin/InfoWidget'
12
import AboutGroup from '../../components/group/AboutGroup'
13
import GroupActions from '../../components/group/GroupActions'
14
 
15
const View = () => {
16
  const [backendVars, setBackendVars] = useState({})
17
  const [actionsUrls, setActionsUrls] = useState({})
18
  const { uuid } = useParams()
19
  const dispatch = useDispatch()
20
 
21
  useEffect(() => {
22
    getBackendVars(`/company/view/${uuid}`)
23
      .then((vars) => {
24
        const actions = {}
25
 
26
        Object.entries(vars).forEach(([key, value]) => {
27
          if (!key.includes('link')) {
28
            return
29
          }
30
 
31
          actions[key] = value
32
        })
33
 
34
        setActionsUrls(actions)
35
        dispatch(setTimelineUrl(vars.link_timeline))
36
        setBackendVars(vars)
37
      })
38
      .catch((err) => {
39
        dispatch(addNotification({ style: 'danger', msg: err }))
40
        console.log(`Error: ${err}`)
41
        throw new Error(err)
42
      })
43
  }, [])
44
 
45
  return (
46
    <main className="w-100">
47
      <div className="container p-0 app__body layout__content">
48
        <div className="d-flex flex-column">
49
          <InfoWidget
50
            cover={backendVars.cover}
51
            image={backendVars.image}
52
            name={backendVars.name}
53
            overview={backendVars.overview}
54
            totalMembers={backendVars.total_members}
55
            id={backendVars.group_uuid}
56
            groupType={backendVars.group_type}
57
            accessibility={backendVars.accessibility}
58
          />
59
        </div>
60
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
61
          <GroupActions {...backendVars} actionLinks={actionsUrls} />
62
 
63
          {backendVars.withoutFeeds ? (
64
            <AboutGroup {...backendVars} />
65
          ) : (
66
            <>
67
              <FeedShare image={backendVars.image} postUrl="/feed/add" />
68
              <FeedList feed={backendVars.feed} image={backendVars.image} />
69
            </>
70
          )}
71
        </div>
72
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
73
          <Members groupId={backendVars.groupId} />
74
          {!backendVars.withoutFeeds && <AboutGroup {...backendVars} />}
75
        </div>
76
      </div>
77
    </main>
78
  )
79
}
80
 
81
export default View