Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
1 www 1
import React from "react";
2
import { useState } from "react";
3
import { connect } from "react-redux";
4
import FeedSection from "../../../dashboard/components/feed-section/FeedSection";
5
import ShareFeed from "../../../dashboard/components/share-feed/ShareFeed";
6
import { setTimelineUrl } from "../../../redux/feed/feed.actions";
7
import { feedTypes } from "../../../redux/feed/feed.types";
8
import GroupMembersHelper from "../../../shared/helpers/group-members-helper/GroupMembersHelper";
9
import SuggestedGroupsHelper from "../../../shared/helpers/suggested-groups-helper/SuggestedGroupsHelper";
10
import styled from "styled-components";
11
import parse from "html-react-parser";
12
import { axios } from "../../../utils";
13
import { addNotification } from "../../../redux/notification/notification.actions";
2437 stevensc 14
import Footer from "../../../shared/helpers/footer/Footer";
1 www 15
 
16
const StyledTabWrapper = styled.div`
17
  ul {
18
    display: flex;
19
    li a {
20
      margin: 1rem;
21
      width: 25px;
22
      display: flex;
23
      flex-direction: column;
24
      justify-content: center;
25
      align-items: center;
26
      color: black;
27
      img {
28
        filter: grayscale(100%);
29
      }
30
    }
31
    li.active a {
32
      img {
33
        filter: grayscale(0);
34
      }
35
    }
36
  }
37
`;
38
 
39
const View = (props) => {
40
  // backendVars Destructuring
41
  const {
42
    routeTimeline,
43
    groupId,
44
    cover,
45
    image,
46
    totalMembers,
47
    name,
48
    overview,
49
    groupType,
50
    industry,
51
    privacy,
52
    accessibility,
53
    website,
54
    withoutFeeds,
55
    linkInmail
56
  } = props.backendVars;
1068 stevensc 57
 
1 www 58
  // redux destructuring
59
  const { setTimelineUrl, addNotification: AddNotification } = props;
60
 
61
  const groupTabs = {
62
    FEED_TAB: "FEED_TAB",
63
    INFO_TAB: "INFO_TAB",
64
  };
1068 stevensc 65
 
1 www 66
  // states
67
  const [currentTab, setCurrentTab] = useState(withoutFeeds ? groupTabs.INFO_TAB : groupTabs.FEED_TAB);
68
  const [actionLinks, setActionLinks] = useState({})
69
  const [linkInvite, setLinkInvite] = useState('')
2246 stevensc 70
 
1 www 71
  setTimelineUrl(routeTimeline);
2246 stevensc 72
  const load = () => {
1 www 73
    axios.get('')
74
      .then(res => {
2246 stevensc 75
        if (res.data.success) {
1 www 76
          setActionLinks(res.data.data)
2246 stevensc 77
        } else {
1 www 78
          AddNotification({
79
            type: 'error',
80
            payload: res.data.data
81
          })
82
        }
83
      })
84
      .catch(err => {
85
        console.log('>>: err > ', err)
86
      })
87
  }
2246 stevensc 88
 
89
  React.useEffect(() => {
1 www 90
    load()
91
  }, [])
1068 stevensc 92
 
1 www 93
  const handleActionLink = (url) => {
94
    axios.post(url)
95
      .then(res => {
2246 stevensc 96
        if (res.data.success) {
1 www 97
          AddNotification({
98
            style: 'success',
99
            msg: res.data.data
100
          })
101
          window.location.reload()
2246 stevensc 102
        } else {
1 www 103
          AddNotification({
104
            style: 'error',
105
            msg: res.data.data
106
          })
107
        }
108
      })
109
      .catch(err => {
110
        console.log('>>: err > ', err)
111
      })
112
  }
2246 stevensc 113
 
1 www 114
  return (
115
    <React.Fragment>
116
      <section className="cover-sec">
117
        <img
118
          // src="<?php echo $this->url('storage', ['type' => 'group-cover', 'code' => $group_id_encrypted, 'filename' => $cover]) ?>"
2246 stevensc 119
          src={`/storage/type/group-cover/code/${groupId}/${cover ? `filename/${cover}` : ""
120
            }`}
1 www 121
          alt="cover-image"
122
        />
123
      </section>
124
      <main>
125
        <div className="main-section">
1765 steven 126
          <div className="ph-5">
1 www 127
            <div className="main-section-data">
2378 stevensc 128
              <div className="main-left-sidebar">
2375 stevensc 129
                <div className="user_profile border-gray overflow-hidden m-0 p-1">
130
                  <div className="user-pro-img">
131
                    <img
132
                      src={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""}`}
133
                      alt="profile-image"
134
                    />
135
                  </div>
136
                  <div className="user_pro_status">
137
                    <h1 className="font-weight-bold" style={{ fontSize: '1.5rem' }} >{name}</h1>
138
                    <ul className="flw-status">
2491 stevensc 139
                      <div className="container horizontal-list">
2375 stevensc 140
                        <div className="row ">
2738 stevensc 141
                          {
142
                            linkInmail
143
                            &&
144
                            <a
145
                              href={linkInmail || '#'}
146
                              className="btn btn-primary"
147
                            >
148
                              Contactar con el Administrador
149
                            </a>
150
                          }
2492 stevensc 151
                          <div className="members_count">
2491 stevensc 152
                            <b style={{ fontSize: '1rem' }} >{totalMembers}</b>
2375 stevensc 153
                            <p>Miembros</p>
154
                          </div>
155
                          {
156
                            actionLinks.link_accept && (
2492 stevensc 157
                              <button
158
                                onClick={() => handleActionLink(actionLinks.link_accept)}
159
                                className="btn btn-primary"
160
                                title=""
161
                              >
162
                                <span className="ellipsis">
163
                                  Aceptar invitacion
164
                                </span>
165
                              </button>
2375 stevensc 166
                            )
167
                          }
168
                          {
169
                            actionLinks.link_cancel && (
2492 stevensc 170
                              <button
171
                                onClick={() => handleActionLink(actionLinks.link_cancel)}
172
                                className="btn btn-primary"
173
                                title=""
174
                              >
175
                                <span className="ellipsis">
176
                                  Cancelar invitacion
177
                                </span>
178
                              </button>
2375 stevensc 179
                            )
180
                          }
181
                          {
182
                            (!linkInvite && actionLinks.link_leave) && (
2492 stevensc 183
                              <button
184
                                onClick={() => handleActionLink(actionLinks.link_leave)}
185
                                className="btn btn-primary"
186
                                title=""
187
                              >
188
                                <span className="ellipsis">
189
                                  Abandonar grupo
190
                                </span>
191
                              </button>
2375 stevensc 192
                            )
193
                          }
194
                          {
195
                            actionLinks.link_request && (
2492 stevensc 196
                              <button
197
                                onClick={() => handleActionLink(actionLinks.link_request)}
198
                                className="btn btn-primary"
199
                                title=""
200
                              >
2609 stevensc 201
                                {accessibility === 'Auto unirse' ? 'Unirse' : 'Solicitar membresia'}
2492 stevensc 202
                              </button>
2375 stevensc 203
                            )
204
                          }
2372 stevensc 205
                        </div>
2375 stevensc 206
                      </div>
2246 stevensc 207
 
2375 stevensc 208
                    </ul>
1 www 209
                  </div>
210
                </div>
2372 stevensc 211
                <GroupMembersHelper groupId={groupId} handleFirstLinkInvite={link => setLinkInvite(link)} />
2375 stevensc 212
              </div>
2372 stevensc 213
              <div className="main-ws-sec">
214
                <div className="user-tab-sec">
215
                  {
216
                    !withoutFeeds && (
217
                      <div className="row">
218
                        <div className="col text-left pl-0">
219
                          <button
220
                            className={` ${currentTab === groupTabs.FEED_TAB ? "active" : ""
221
                              } animated fadeIn btn btn-link p-0 text-decoration-none`}
222
                            onClick={(e) => {
223
                              e.preventDefault();
224
                              setCurrentTab(groupTabs.FEED_TAB);
1 www 225
 
2372 stevensc 226
                            }}
227
                          >
228
                            <span className="ellipsis text-dark font-weight-bold">Ver Publicaciones</span>
229
                          </button>
230
                        </div>
231
                        <div className="col text-right pl-0">
232
                          <button
233
                            className={` ${currentTab === groupTabs.INFO_TAB ? "active" : ""
234
                              } animated fadeIn btn btn-link p-0 text-decoration-none`}
235
                            onClick={(e) => {
236
                              e.preventDefault();
237
                              setCurrentTab(groupTabs.INFO_TAB);
238
                            }}
239
                          >
240
                            <span className="ellipsis text-dark font-weight-bold">Ver Información</span>
241
                          </button>
242
                        </div>
243
                      </div>
244
                    )
245
                  }
246
                  {/* <!-- tab-feed end--> */}
247
                </div>
248
                {/* <!--user-tab-sec end--> */}
2246 stevensc 249
 
2372 stevensc 250
                <div
251
                  className="product-feed-tab animated fadeIn"
252
                  id="feed-dd"
253
                  style={{
254
                    display:
255
                      currentTab === groupTabs.FEED_TAB ? "block" : "none",
256
                  }}
257
                >
258
                  <ShareFeed
259
                    feedType={feedTypes.GROUP}
260
                    postUrl={`/feed/add/group/${groupId}`}
2897 stevensc 261
                    image={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""}`}
2372 stevensc 262
                  />
263
                  {/* <!--posts-section star--> */}
264
                  <div className="posts-section">
2897 stevensc 265
                    <FeedSection
266
                      routeTimeline={routeTimeline}
267
                      image={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""}`}
268
                    />
1 www 269
                  </div>
2372 stevensc 270
                  {/* <!--posts-section end--> */}
271
                </div>
272
                {/* <!--product-feed-tab end--> */}
273
 
274
                <div
275
                  className="product-feed-tab  animated fadeIn"
276
                  id="info-dd"
2913 stevensc 277
                  style={{ display: currentTab === groupTabs.INFO_TAB ? "flex" : "none", }}
2372 stevensc 278
                >
1 www 279
                  <div className="main-ws-sec">
2372 stevensc 280
                    {/* <!--user-tab-sec start--> */}
281
                    {!!overview && (
282
                      <div className="user-profile-extended-ov">
283
                        <h3>Visión General</h3>
284
                        <span id="overview-description">
285
                          {parse(overview)}
286
                        </span>
287
                      </div>
288
                    )}
289
                    {/* <!--user-tab-sec endit--> */}
2246 stevensc 290
 
2372 stevensc 291
                    {/* <!--user-tab-sec start--> */}
292
                    {!!groupType && (
293
                      <div className="user-profile-extended-ov">
294
                        <h3>Tipo</h3>
295
                        <span id="overview-type">{groupType}</span>
296
                      </div>
297
                    )}
298
                    {/* <!--user-tab-sec endit--> */}
1 www 299
 
2372 stevensc 300
                    {/* <!--user-tab-sec start--> */}
301
                    {!!industry && (
302
                      <div className="user-profile-extended-ov">
303
                        <h3>Industria</h3>
304
                        <span id="overview-industry">{industry}</span>
1 www 305
                      </div>
2372 stevensc 306
                    )}
307
                    {/* <!--user-tab-sec endit--> */}
1 www 308
 
2372 stevensc 309
                    {/* <!--user-tab-sec start--> */}
310
                    {/* <?php if($privacy) : ?> */}
311
                    {!!privacy && (
312
                      <div className="user-profile-extended-ov">
313
                        <h3>Privacidad</h3>
314
                        <span id="overview-privacy">{privacy}</span>
315
                      </div>
316
                    )}
317
                    {/* <!--user-tab-sec endit--> */}
1 www 318
 
2372 stevensc 319
                    {/* <!--user-tab-sec start--> */}
320
                    {!!accessibility && (
321
                      <div className="user-profile-extended-ov">
322
                        <h3>Accesibilidad</h3>
323
                        <span id="overview-accessibility">
324
                          {accessibility}
325
                        </span>
326
                      </div>
327
                    )}
328
                    {/* <!--user-tab-sec endit--> */}
1 www 329
 
2372 stevensc 330
                    {/* <!--user-tab-sec start--> */}
331
                    {!!website && (
332
                      <div className="user-profile-extended-ov">
333
                        <h3>Página Web</h3>
334
                        <span id="overview-website">{website}</span>
335
                      </div>
336
                    )}
337
                    {/* <!--user-tab-sec endit--> */}
1 www 338
 
2372 stevensc 339
                    {/* <!--user-profile-ov end--> */}
1 www 340
                  </div>
2372 stevensc 341
                  {/* <!--main-ws-sec end--> */}
1 www 342
                </div>
343
              </div>
2372 stevensc 344
              <SuggestedGroupsHelper groupId={groupId} />
1 www 345
            </div>
2492 stevensc 346
          </div >
347
        </div >
348
      </main >
349
    </React.Fragment >
1 www 350
  );
351
};
352
 
353
const mapDispatchToProps = {
354
  setTimelineUrl: (url) => setTimelineUrl(url),
355
  addNotification: (notification) => addNotification(notification),
356
};
357
 
358
 
359
export default connect(null, mapDispatchToProps)(View);