Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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