Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
3546 stevensc 1
/* eslint-disable react/prop-types */
5793 stevensc 2
import React, { useEffect, useState } from 'react'
3
import parse from 'html-react-parser'
4
import { axios } from '../../../utils'
5
import { connect } from 'react-redux'
6
import { setTimelineUrl } from '../../../redux/feed/feed.actions'
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import { feedTypes } from '../../../redux/feed/feed.types'
9
import FeedSection from '../../../dashboard/components/feed-section/FeedSection'
10
import ShareFeed from '../../../dashboard/components/share-feed/ShareFeed'
11
import GroupMembersHelper from '../../../shared/helpers/group-members-helper/GroupMembersHelper'
12
import GroupAttr from './component/GroupAttr'
13
import Cover from '../../../shared/cover/Cover'
14
import SuggestWidget from '../../../shared/helpers/my-groups-helper/SuggestWidget'
1 www 15
 
16
const View = (props) => {
17
  // backendVars Destructuring
18
  const {
19
    routeTimeline,
20
    groupId,
21
    cover,
22
    image,
23
    totalMembers,
24
    name,
25
    overview,
26
    groupType,
27
    industry,
28
    privacy,
29
    accessibility,
30
    website,
31
    withoutFeeds,
5793 stevensc 32
    linkInmail,
33
  } = props.backendVars
1068 stevensc 34
 
1 www 35
  // redux destructuring
5793 stevensc 36
  const { setTimelineUrl, addNotification } = props
1 www 37
 
38
  const groupTabs = {
5793 stevensc 39
    FEED_TAB: 'FEED_TAB',
40
    INFO_TAB: 'INFO_TAB',
41
  }
1068 stevensc 42
 
1 www 43
  // states
5793 stevensc 44
  const [currentTab, setCurrentTab] = useState(
45
    withoutFeeds ? groupTabs.INFO_TAB : groupTabs.FEED_TAB
46
  )
1 www 47
  const [actionLinks, setActionLinks] = useState({})
48
  const [linkInvite, setLinkInvite] = useState('')
2246 stevensc 49
 
5793 stevensc 50
  setTimelineUrl(routeTimeline)
3903 stevensc 51
 
2246 stevensc 52
  const load = () => {
5793 stevensc 53
    axios
54
      .get('')
3903 stevensc 55
      .then(({ data }) => {
56
        if (!data.success) {
57
          return addNotification({ style: 'error', msg: data.data })
1 www 58
        }
3903 stevensc 59
        setActionLinks(data.data)
1 www 60
      })
5793 stevensc 61
      .catch((err) => console.log('>>: err > ', err))
1 www 62
  }
2246 stevensc 63
 
3903 stevensc 64
  useEffect(() => {
1 www 65
    load()
66
  }, [])
1068 stevensc 67
 
1 www 68
  const handleActionLink = (url) => {
5793 stevensc 69
    axios
70
      .post(url)
3903 stevensc 71
      .then(({ data }) => {
72
        if (!data.success) {
73
          return addNotification({ style: 'error', msg: data.data })
1 www 74
        }
3903 stevensc 75
        addNotification({ style: 'success', msg: data.data })
76
        window.location.reload()
1 www 77
      })
5793 stevensc 78
      .catch((err) => console.log('>>: err > ', err))
1 www 79
  }
2246 stevensc 80
 
1 www 81
  return (
3903 stevensc 82
    <>
5793 stevensc 83
      <Cover cover={cover} id={groupId} type="group" />
84
 
85
      <main className="main-section-data container px-0 mt-3">
86
        <div className="main-left-sidebar">
87
          <div className="user_profile">
88
            <div className="user-pro-img">
89
              <img
90
                src={`/storage/type/group/code/${groupId}/${
91
                  image ? `filename/${image}` : ''
92
                }`}
93
                alt="profile-image"
94
              />
95
            </div>
96
            <div className="user_pro_status">
97
              <h1 className="font-weight-bold" style={{ fontSize: '1.5rem' }}>
98
                {name}
99
              </h1>
100
              <ul className="flw-status">
101
                <div className="container horizontal-list">
102
                  <div className="row ">
103
                    {linkInmail && (
104
                      <a href={linkInmail || '#'} className="btn btn-primary">
105
                        Contactar con el Administrador
106
                      </a>
107
                    )}
108
                    <div className="members_count">
109
                      <b style={{ fontSize: '1rem' }}>{totalMembers}</b>
110
                      <p>Miembros</p>
3845 stevensc 111
                    </div>
5793 stevensc 112
                    {actionLinks.link_accept && (
113
                      <button
114
                        onClick={() =>
115
                          handleActionLink(actionLinks.link_accept)
116
                        }
117
                        className="btn btn-primary"
118
                      >
119
                        Aceptar invitacion
120
                      </button>
121
                    )}
122
                    {actionLinks.link_cancel && (
123
                      <button
124
                        onClick={() =>
125
                          handleActionLink(actionLinks.link_cancel)
126
                        }
127
                        className="btn btn-primary"
128
                      >
129
                        Cancelar invitacion
130
                      </button>
131
                    )}
132
                    {!linkInvite && actionLinks.link_leave && (
133
                      <button
134
                        onClick={() => handleActionLink(actionLinks.link_leave)}
135
                        className="btn btn-primary"
136
                      >
137
                        Abandonar grupo
138
                      </button>
139
                    )}
140
                    {actionLinks.link_request && (
141
                      <button
142
                        onClick={() =>
143
                          handleActionLink(actionLinks.link_request)
144
                        }
145
                        className="btn btn-primary"
146
                      >
147
                        {accessibility === 'Auto unirse'
148
                          ? 'Unirse'
149
                          : 'Solicitar membresia'}
150
                      </button>
151
                    )}
1 www 152
                  </div>
5793 stevensc 153
                </div>
154
              </ul>
3903 stevensc 155
            </div>
156
          </div>
5793 stevensc 157
          <GroupMembersHelper
158
            groupId={groupId}
159
            handleFirstLinkInvite={(link) => setLinkInvite(link)}
160
          />
161
        </div>
162
        <div className="main-ws-sec">
163
          <div className="user-tab-sec">
164
            {!withoutFeeds && (
165
              <div className="row">
166
                <div className="col text-left pl-0">
167
                  <button
168
                    className={` ${
169
                      currentTab === groupTabs.FEED_TAB ? 'active' : ''
170
                    } animated fadeIn btn btn-link p-0 text-decoration-none`}
171
                    onClick={() => setCurrentTab(groupTabs.FEED_TAB)}
172
                  >
173
                    <span className="font-weight-bold">Ver Publicaciones</span>
174
                  </button>
1 www 175
                </div>
5793 stevensc 176
                <div className="col text-right pr-0">
177
                  <button
178
                    className={` ${
179
                      currentTab === groupTabs.INFO_TAB ? 'active' : ''
180
                    } animated fadeIn btn btn-link p-0 text-decoration-none`}
181
                    onClick={() => setCurrentTab(groupTabs.INFO_TAB)}
182
                  >
183
                    <span className="font-weight-bold">Ver Información</span>
184
                  </button>
185
                </div>
186
              </div>
187
            )}
188
          </div>
189
          {currentTab === groupTabs.FEED_TAB && (
190
            <div className="product-feed-tab fadeIn">
3903 stevensc 191
              <ShareFeed
192
                feedType={feedTypes.GROUP}
193
                postUrl={`/feed/add/group/${groupId}`}
5793 stevensc 194
                image={`/storage/type/group/code/${groupId}/${
195
                  image ? `filename/${image}` : ''
196
                }`}
3903 stevensc 197
              />
198
              <div className="posts-section">
199
                <FeedSection
200
                  routeTimeline={routeTimeline}
5793 stevensc 201
                  image={`/storage/type/group/code/${groupId}/${
202
                    image ? `filename/${image}` : ''
203
                  }`}
3903 stevensc 204
                />
1 www 205
              </div>
3903 stevensc 206
            </div>
5793 stevensc 207
          )}
208
          {currentTab === groupTabs.INFO_TAB && (
209
            <div className="product-feed-tab fadeIn">
210
              {overview && (
211
                <GroupAttr title="Visión General">
212
                  <span>{parse(overview)}</span>
213
                </GroupAttr>
214
              )}
215
              {groupType && (
216
                <GroupAttr title="Tipo">
217
                  <span>{groupType}</span>
218
                </GroupAttr>
219
              )}
220
              {industry && (
221
                <GroupAttr title="Industria">
222
                  <span>{industry}</span>
223
                </GroupAttr>
224
              )}
225
              {!!privacy && (
226
                <GroupAttr title="Privacidad">
227
                  <span>{privacy}</span>
228
                </GroupAttr>
229
              )}
230
              {!!accessibility && (
231
                <GroupAttr title="Accesibilidad">
232
                  <span>{accessibility}</span>
233
                </GroupAttr>
234
              )}
235
              {!!website && (
236
                <GroupAttr title="Página Web">
237
                  <span>{website}</span>
238
                </GroupAttr>
239
              )}
1 www 240
            </div>
5793 stevensc 241
          )}
3903 stevensc 242
        </div>
5793 stevensc 243
        <div className="right-sidebar">
244
          <SuggestWidget title="Grupos:" url="/helpers/groups-suggestion" />
245
        </div>
246
      </main>
3903 stevensc 247
    </>
5793 stevensc 248
  )
249
}
1 www 250
 
251
const mapDispatchToProps = {
252
  setTimelineUrl: (url) => setTimelineUrl(url),
253
  addNotification: (notification) => addNotification(notification),
5793 stevensc 254
}
1 www 255
 
5793 stevensc 256
export default connect(null, mapDispatchToProps)(View)