Rev 6891 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect, useState } from 'react'
import { camalize } from '../../utils'
import { useParams } from 'react-router-dom'
import { useDispatch } from 'react-redux'
import { getBackendVars } from '../../services/backendVars'
import { setTimelineUrl } from '../../redux/feed/feed.actions'
import { addNotification } from '../../redux/notification/notification.actions'
import Members from '../../components/group/Members'
import FeedList from '../../components/feed/linkedin/FeedList'
import FeedShare from '../../components/feed/linkedin/FeedShare'
import InfoWidget from '../../components/widgets/linkedin/InfoWidget'
import AboutGroup from '../../components/group/AboutGroup'
import GroupActions from '../../components/group/GroupActions'
import './styles/linkedin.scss'
const View = () => {
const [backendVars, setBackendVars] = useState({})
const { uuid } = useParams()
const dispatch = useDispatch()
const getGroup = () => {
getBackendVars(`/group/view/${uuid}`)
.then((vars) => {
const actions = {}
Object.entries(vars).forEach(([key, value]) => {
const camelCaseKey = camalize(key)
actions[camelCaseKey] = value
})
dispatch(setTimelineUrl(`/feed/timeline/${vars.group_uuid}/group`))
setBackendVars(actions)
})
.catch((err) => {
dispatch(addNotification({ style: 'danger', msg: err }))
console.log(`Error: ${err}`)
throw new Error(err)
})
}
useEffect(() => {
getGroup()
}, [])
return (
<main className="w-100">
<div className="container p-0 app__body layout__content">
<div className="d-flex flex-column">
<InfoWidget {...backendVars} />
</div>
<div className="d-flex flex-column" style={{ gap: '.5rem' }}>
<GroupActions {...backendVars} refetch={getGroup} />
{backendVars.withoutFeeds ? (
<AboutGroup {...backendVars} />
) : (
<>
<FeedShare
feedType="GROUP"
postUrl={`/feed/add/group/${uuid}`}
image={`/storage/type/group/code/${uuid}${
backendVars.image ? `/filename/${backendVars.image}` : '/'
}`}
/>
<FeedList feed={backendVars.feed} image={backendVars.image} />
</>
)}
</div>
<div className="d-flex flex-column" style={{ gap: '.5rem' }}>
<Members groupId={backendVars.groupUuid} />
{!backendVars.withoutFeeds && <AboutGroup {...backendVars} />}
</div>
</div>
</main>
)
}
export default View