Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6863 | Rev 6865 | Ir a la última revisión | | Comparar con el anterior | 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(() => {
6863 stevensc 22
    getBackendVars(`/group/view/${uuid}`)
6862 stevensc 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' }}>
6864 stevensc 61
          <GroupActions
62
            groupId={backendVars.group_uuid}
63
            groupType={backendVars.group_type}
64
            linkInmail={backendVars.link_inmail}
65
            {...backendVars}
66
            actionLinks={actionsUrls}
67
          />
6862 stevensc 68
 
69
          {backendVars.withoutFeeds ? (
70
            <AboutGroup {...backendVars} />
71
          ) : (
72
            <>
73
              <FeedShare image={backendVars.image} postUrl="/feed/add" />
74
              <FeedList feed={backendVars.feed} image={backendVars.image} />
75
            </>
76
          )}
77
        </div>
78
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
6864 stevensc 79
          <Members groupId={backendVars.group_uuid} />
6862 stevensc 80
          {!backendVars.withoutFeeds && <AboutGroup {...backendVars} />}
81
        </div>
82
      </div>
83
    </main>
84
  )
85
}
86
 
87
export default View