Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6891 | | 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'
6865 stevensc 2
import { camalize } from '../../utils'
6862 stevensc 3
import { useParams } from 'react-router-dom'
4
import { useDispatch } from 'react-redux'
5
import { getBackendVars } from '../../services/backendVars'
6
import { setTimelineUrl } from '../../redux/feed/feed.actions'
7
import { addNotification } from '../../redux/notification/notification.actions'
8
 
9
import Members from '../../components/group/Members'
10
import FeedList from '../../components/feed/linkedin/FeedList'
11
import FeedShare from '../../components/feed/linkedin/FeedShare'
12
import InfoWidget from '../../components/widgets/linkedin/InfoWidget'
13
import AboutGroup from '../../components/group/AboutGroup'
14
import GroupActions from '../../components/group/GroupActions'
15
 
6869 stevensc 16
import './styles/linkedin.scss'
17
 
6862 stevensc 18
const View = () => {
19
  const [backendVars, setBackendVars] = useState({})
20
  const { uuid } = useParams()
21
  const dispatch = useDispatch()
22
 
6892 stevensc 23
  const getGroup = () => {
6863 stevensc 24
    getBackendVars(`/group/view/${uuid}`)
6862 stevensc 25
      .then((vars) => {
26
        const actions = {}
27
 
28
        Object.entries(vars).forEach(([key, value]) => {
6865 stevensc 29
          const camelCaseKey = camalize(key)
30
          actions[camelCaseKey] = value
6862 stevensc 31
        })
32
 
6883 stevensc 33
        dispatch(setTimelineUrl(`/feed/timeline/${vars.group_uuid}/group`))
6865 stevensc 34
        setBackendVars(actions)
6862 stevensc 35
      })
36
      .catch((err) => {
37
        dispatch(addNotification({ style: 'danger', msg: err }))
38
        console.log(`Error: ${err}`)
39
        throw new Error(err)
40
      })
6892 stevensc 41
  }
42
 
43
  useEffect(() => {
44
    getGroup()
6862 stevensc 45
  }, [])
46
 
47
  return (
48
    <main className="w-100">
49
      <div className="container p-0 app__body layout__content">
50
        <div className="d-flex flex-column">
6865 stevensc 51
          <InfoWidget {...backendVars} />
6862 stevensc 52
        </div>
53
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
6892 stevensc 54
          <GroupActions {...backendVars} refetch={getGroup} />
6862 stevensc 55
 
56
          {backendVars.withoutFeeds ? (
57
            <AboutGroup {...backendVars} />
58
          ) : (
59
            <>
6865 stevensc 60
              <FeedShare
61
                feedType="GROUP"
62
                postUrl={`/feed/add/group/${uuid}`}
6891 stevensc 63
                image={`/storage/type/group/code/${uuid}${
64
                  backendVars.image ? `/filename/${backendVars.image}` : '/'
65
                }`}
6865 stevensc 66
              />
6862 stevensc 67
              <FeedList feed={backendVars.feed} image={backendVars.image} />
68
            </>
69
          )}
70
        </div>
71
        <div className="d-flex flex-column" style={{ gap: '.5rem' }}>
6868 stevensc 72
          <Members groupId={backendVars.groupUuid} />
6862 stevensc 73
          {!backendVars.withoutFeeds && <AboutGroup {...backendVars} />}
74
        </div>
75
      </div>
76
    </main>
77
  )
78
}
79
 
80
export default View