Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
6894 stevensc 1
import React, { useState, useEffect } from 'react'
2
import { camalize } from '../../utils'
3
import { useParams } from 'react-router-dom'
4
import { useDispatch } from 'react-redux'
5
import { getBackendVars } from '../../services/backendVars'
6
import { addNotification } from '../../redux/notification/notification.actions'
7
 
8
import Overview from '../../components/overview/Overview'
9
import GroupActions from '../../components/group/GroupActions'
10
 
6902 stevensc 11
import Type from '../../components/group/type/Type'
6899 stevensc 12
import Website from '../../components/group/website/Website'
13
import Privacy from '../../components/group/privacy/Privacy'
14
import Industry from '../../components/group/industry/Industry'
15
// import Accessibility from '../../components/group/accessibility/Accessibility'
16
 
6894 stevensc 17
import './styles/linkedin.scss'
18
 
19
const Edit = () => {
20
  const [backendVars, setBackendVars] = useState({})
21
  const dispatch = useDispatch()
22
  const { uuid } = useParams()
23
 
6899 stevensc 24
  const changePrivacy = (privacy) => {
25
    setBackendVars((prevBackendVars) => {
26
      return {
27
        ...prevBackendVars,
28
        privacy,
29
      }
30
    })
31
  }
32
 
6894 stevensc 33
  useEffect(() => {
6897 stevensc 34
    getBackendVars(`/group/my-groups/edit/${uuid}`)
6894 stevensc 35
      .then((vars) => {
36
        const actions = {}
37
 
38
        Object.entries(vars).forEach(([key, value]) => {
39
          const camelCaseKey = camalize(key)
40
          actions[camelCaseKey] = value
41
        })
42
 
43
        setBackendVars(actions)
44
        console.log(actions)
45
      })
46
      .catch((err) => {
47
        dispatch(addNotification({ style: 'danger', msg: err }))
48
        console.log(`Error: ${err}`)
49
        throw new Error(err)
50
      })
51
  }, [])
52
 
53
  return (
54
    <main className="w-100">
55
      <div className="container">
56
        <div className="main d-flex flex-column" style={{ gap: '1rem' }}>
6902 stevensc 57
          <GroupActions
58
            {...backendVars}
59
            coverSize={backendVars?.imageSizeCover}
60
            imageSize={backendVars?.imageSizeProfile}
61
          />
6894 stevensc 62
          <Overview groupId={uuid} overview={backendVars?.overview} />
6902 stevensc 63
          <Type
6899 stevensc 64
            groupId={uuid}
6902 stevensc 65
            type={backendVars?.groupType}
66
            types={backendVars?.groupTypes}
67
          />
6894 stevensc 68
          <Industry
6899 stevensc 69
            groupId={uuid}
70
            industry={backendVars?.industry}
71
            industries={backendVars?.industries}
6894 stevensc 72
          />
73
          <Privacy
6899 stevensc 74
            groupId={uuid}
75
            privacy={backendVars?.privacy}
76
            privacies={backendVars?.privacies}
77
            onChange={changePrivacy}
6894 stevensc 78
          />
6899 stevensc 79
          {/* <Accessibility
80
            groupId={uuid}
81
            privacy={settedPrivacy}
6894 stevensc 82
            accessibility={settedAccesibility}
6899 stevensc 83
            accessibilities={backendVars?.accessibilities}
6894 stevensc 84
            setSettedAccesibility={setSettedAccesibility}
6899 stevensc 85
          /> */}
86
          <Website groupId={uuid} website={backendVars?.website} />
6894 stevensc 87
        </div>
88
      </div>
89
    </main>
90
  )
91
}
92
 
93
export default Edit