Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Rev 1756 | 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";
14
 
15
const StyledTabWrapper = styled.div`
16
  ul {
17
    display: flex;
18
    li a {
19
      margin: 1rem;
20
      width: 25px;
21
      display: flex;
22
      flex-direction: column;
23
      justify-content: center;
24
      align-items: center;
25
      color: black;
26
      img {
27
        filter: grayscale(100%);
28
      }
29
    }
30
    li.active a {
31
      img {
32
        filter: grayscale(0);
33
      }
34
    }
35
  }
36
`;
37
 
38
const View = (props) => {
39
  // backendVars Destructuring
40
  const {
41
    routeTimeline,
42
    groupId,
43
    cover,
44
    image,
45
    totalMembers,
46
    name,
47
    overview,
48
    groupType,
49
    industry,
50
    privacy,
51
    accessibility,
52
    website,
53
    withoutFeeds,
54
    linkInmail
55
  } = props.backendVars;
1068 stevensc 56
 
1 www 57
  // redux destructuring
58
  const { setTimelineUrl, addNotification: AddNotification } = props;
59
 
60
  const groupTabs = {
61
    FEED_TAB: "FEED_TAB",
62
    INFO_TAB: "INFO_TAB",
63
  };
1068 stevensc 64
 
1 www 65
  // states
66
  const [currentTab, setCurrentTab] = useState(withoutFeeds ? groupTabs.INFO_TAB : groupTabs.FEED_TAB);
67
  const [actionLinks, setActionLinks] = useState({})
68
  const [linkInvite, setLinkInvite] = useState('')
1068 stevensc 69
 
1 www 70
  setTimelineUrl(routeTimeline);
71
  const load = () =>{
72
    axios.get('')
73
      .then(res => {
74
        if(res.data.success){
75
          setActionLinks(res.data.data)
76
        }else{
77
          AddNotification({
78
            type: 'error',
79
            payload: res.data.data
80
          })
81
        }
82
      })
83
      .catch(err => {
84
        console.log('>>: err > ', err)
85
      })
86
  }
1068 stevensc 87
 
1 www 88
  React.useEffect(() =>{
89
    load()
90
  }, [])
1068 stevensc 91
 
1 www 92
  const handleActionLink = (url) => {
93
    axios.post(url)
94
      .then(res => {
95
        if(res.data.success){
96
          AddNotification({
97
            style: 'success',
98
            msg: res.data.data
99
          })
100
          window.location.reload()
101
        }else{
102
          AddNotification({
103
            style: 'error',
104
            msg: res.data.data
105
          })
106
        }
107
      })
108
      .catch(err => {
109
        console.log('>>: err > ', err)
110
      })
111
  }
1068 stevensc 112
 
1 www 113
  return (
114
    <React.Fragment>
115
      <section className="cover-sec">
116
        <img
117
          // src="<?php echo $this->url('storage', ['type' => 'group-cover', 'code' => $group_id_encrypted, 'filename' => $cover]) ?>"
118
          src={`/storage/type/group-cover/code/${groupId}/${
119
            cover ? `filename/${cover}` : ""
120
          }`}
121
          alt="cover-image"
122
        />
123
      </section>
124
      <main>
125
        <div className="main-section">
126
          <div className="container">
127
            <div className="main-section-data">
128
              <div className="row">
129
                <div className="col-lg-3">
130
                  <div className="main-left-sidebar">
131
                    <div className="user_profile">
132
                      <div className="user-pro-img">
133
                        <img
134
                          // src="<?php echo $this->url('storage', ['type' => 'group', 'code' => $group_id_encrypted, 'filename' => $image]) ?>"
135
                          src={`/storage/type/group/code/${groupId}/${
136
                            image ? `filename/${image}` : ""
137
                          }`}
138
                          alt="profile-image"
139
                        />
140
                      </div>
141
                      <div className="user_pro_status">
142
                        <h1  className="font-weight-bold" style={{fontSize: '1.5rem'}} >{name}</h1>
143
                        <ul className="flw-status">
144
                          <li>
145
                            <p>Miembros</p>
146
                            <b style={{fontSize: '1rem'}} >{totalMembers}</b>
147
                          </li>
148
                        </ul>
149
                      </div>
150
                    </div>
151
                  </div>
152
                  <GroupMembersHelper groupId={groupId} handleFirstLinkInvite={link => setLinkInvite(link)} />
153
                </div>
154
 
155
                <div className="col-lg-6">
156
                  <div className="message-btn d-block d-md-none d-lg-none d-sm-none">
157
                    <a
158
                      href={linkInmail || '#'}
159
                      className="btn-send-message"
160
                      title=""
161
                    >
162
                      <i className="fa fa-envelope"></i> Mensaje
163
                    </a>
164
                    {
165
                      actionLinks.link_accept && (
166
                        <a
167
                          href="#"
168
                          onClick={() => handleActionLink(actionLinks.link_accept)}
169
                          className="btn btn-success"
170
                          title=""
171
                        >
172
                          <i className="fa fa-check"></i> Aceptar invitacion
173
                        </a>
174
                      )
175
                    }
176
                    {
177
                      actionLinks.link_cancel && (
178
                        <a
179
                          href="#"
180
                          onClick={() => handleActionLink(actionLinks.link_cancel)}
181
                          className="btn btn-danger"
182
                          title=""
183
                        >
184
                          <i className="fa fa-close"></i> Cancelar invitacion
185
                        </a>
186
                      )
187
                    }
188
                    {
189
                      (!linkInvite && actionLinks.link_leave) && (
190
                        <a
191
                          href="#"
192
                          onClick={() => handleActionLink(actionLinks.link_leave)}
193
                          className="btn btn-danger"
194
                          title=""
195
                        >
196
                          <i className="fas fa-door-open"></i> Abandonar grupo
197
                        </a>
198
                      )
199
                    }
200
                    {
201
                      actionLinks.link_request && (
202
                        <a
203
                          href="#"
204
                          onClick={() => handleActionLink(actionLinks.link_request)}
205
                          className="btn btn-primary"
206
                          title=""
207
                        >
208
                          <i className="fa fa-plus"></i> Solicitar membresia
209
                        </a>
210
                      )
211
                    }
212
                  </div>
213
                  <div className="main-ws-sec">
214
                    <div className="user-tab-sec">
215
                      {
216
                        !withoutFeeds && (
217
                          <StyledTabWrapper>
218
                            <ul>
219
                              <li
220
                                className={` ${
221
                                  currentTab === groupTabs.FEED_TAB ? "active" : ""
222
                                } animated fadeIn`}
223
                                onClick={(e) => {
224
                                  e.preventDefault();
225
                                  setCurrentTab(groupTabs.FEED_TAB);
226
                                   (groupTabs.FEED_TAB);
227
                                }}
228
                              >
229
                                <a href="#" title="">
230
                                  <img
231
                                    // src="<?php echo $this->basePath('images/ic1.png') ?>"
232
                                    src="/images/ic1.png"
233
                                    alt=""
234
                                  />
235
                                  <span>Publicaciones</span>
236
                                </a>
237
                              </li>
238
                              <li
239
                                className={`${
240
                                  currentTab === groupTabs.INFO_TAB ? "active" : ""
241
                                } animated fadeIn group-view-tab`}
242
                                onClick={(e) => {
243
                                  e.preventDefault();
244
                                  setCurrentTab(groupTabs.INFO_TAB);
245
                                   (groupTabs.INFO_TAB);
246
                                }}
247
                              >
248
                                <a href="#" title="">
249
                                  <img
250
                                    // src="<?php echo $this->basePath('images/ic2.png') ?>"
251
                                    src="/images/ic2.png"
252
                                    alt=""
253
                                  />
254
                                  <span className="ellipsis">Info. del grupo</span>
255
                                </a>
256
                              </li>
257
                            </ul>
258
                          </StyledTabWrapper>
259
                        )
260
                      }
261
                      {/* <!-- tab-feed end--> */}
262
                    </div>
263
                    {/* <!--user-tab-sec end--> */}
264
 
265
                    <div
266
                      className="product-feed-tab animated fadeIn"
267
                      id="feed-dd"
268
                      style={{
269
                        display:
270
                          currentTab === groupTabs.FEED_TAB ? "block" : "none",
271
                      }}
272
                    >
273
                      <div className="">
274
                        <ShareFeed
275
                          feedType={feedTypes.GROUP}
276
                          postUrl={`/feed/add/group/${groupId}`}
277
                        />
278
                      </div>
279
                      {/* <!--posts-section star--> */}
280
                      <div className="posts-section">
281
                        <FeedSection routeTimeline={routeTimeline} />
282
                      </div>
283
                      {/* <!--posts-section end--> */}
284
                    </div>
285
                    {/* <!--product-feed-tab end--> */}
286
 
287
                    <div
288
                      className="product-feed-tab  animated fadeIn"
289
                      id="info-dd"
290
                      style={{
291
                        display:
292
                          currentTab === groupTabs.INFO_TAB ? "block" : "none",
293
                      }}
294
                    >
295
                      <div className="main-ws-sec">
296
                        {/* <!--user-tab-sec start--> */}
297
                        {!!overview && (
298
                          <div className="user-profile-extended-ov">
299
                            <h3>Visión General</h3>
300
                            <span id="overview-description">
301
                              {parse(overview)}
302
                            </span>
303
                          </div>
304
                        )}
305
                        {/* <!--user-tab-sec endit--> */}
306
 
307
                        {/* <!--user-tab-sec start--> */}
308
                        {!!groupType && (
309
                          <div className="user-profile-extended-ov">
310
                            <h3>Tipo</h3>
311
                            <span id="overview-type">{groupType}</span>
312
                          </div>
313
                        )}
314
                        {/* <!--user-tab-sec endit--> */}
315
 
316
                        {/* <!--user-tab-sec start--> */}
317
                        {!!industry && (
318
                          <div className="user-profile-extended-ov">
319
                            <h3>Industria</h3>
320
                            <span id="overview-industry">{industry}</span>
321
                          </div>
322
                        )}
323
                        {/* <!--user-tab-sec endit--> */}
324
 
325
                        {/* <!--user-tab-sec start--> */}
326
                        {/* <?php if($privacy) : ?> */}
327
                        {!!privacy && (
328
                          <div className="user-profile-extended-ov">
329
                            <h3>Privacidad</h3>
330
                            <span id="overview-privacy">{privacy}</span>
331
                          </div>
332
                        )}
333
                        {/* <!--user-tab-sec endit--> */}
334
 
335
                        {/* <!--user-tab-sec start--> */}
336
                        {!!accessibility && (
337
                          <div className="user-profile-extended-ov">
338
                            <h3>Accesibilidad</h3>
339
                            <span id="overview-accessibility">
340
                              {accessibility}
341
                            </span>
342
                          </div>
343
                        )}
344
                        {/* <!--user-tab-sec endit--> */}
345
 
346
                        {/* <!--user-tab-sec start--> */}
347
                        {!!website && (
348
                          <div className="user-profile-extended-ov">
349
                            <h3>Página Web</h3>
350
                            <span id="overview-website">{website}</span>
351
                          </div>
352
                        )}
353
                        {/* <!--user-tab-sec endit--> */}
354
 
355
                        {/* <!--user-profile-ov end--> */}
356
                      </div>
357
                      {/* <!--main-ws-sec end--> */}
358
                    </div>
359
                  </div>
360
                </div>
361
                {/* <!--main-ws-sec end--> */}
362
 
363
                <div className="col-lg-3 d-sm-none d-none d-md-block d-lg-block">
364
                  <div className="right-sidebar">
365
                    <div className="message-btn">
366
                      <a
367
                        href={linkInmail || '#'}
368
                        className="btn-send-message"
369
                        title=""
370
                      >
371
                        <i className="fa fa-envelope"></i> Mensaje
372
                      </a>
373
                      {
374
                        actionLinks.link_accept && (
375
                          <a
376
                            href="#"
377
                            onClick={() => handleActionLink(actionLinks.link_accept)}
378
                            className="btn btn-success"
379
                            title=""
380
                          >
381
                            <i className="fa fa-check"></i> Aceptar invitacion
382
                          </a>
383
                        )
384
                      }
385
                      {
386
                        actionLinks.link_cancel && (
387
                          <a
388
                            href="#"
389
                            onClick={() => handleActionLink(actionLinks.link_cancel)}
390
                            className="btn btn-danger"
391
                            title=""
392
                          >
393
                            <i className="fa fa-close"></i> Cancelar invitacion
394
                          </a>
395
                        )
396
                      }
397
                      {
398
                        (!linkInvite && actionLinks.link_leave) && (
399
                          <a
400
                            href="#"
401
                            onClick={() => handleActionLink(actionLinks.link_leave)}
402
                            className="btn btn-danger"
403
                            title=""
404
                          >
405
                            <i className="fas fa-door-open"></i> Abandonar grupo
406
                          </a>
407
                        )
408
                      }
409
                      {
410
                        actionLinks.link_request && (
411
                          <a
412
                            href="#"
413
                            onClick={() => handleActionLink(actionLinks.link_request)}
414
                            className="btn btn-primary"
415
                            title=""
416
                          >
417
                            <i className="fa fa-plus"></i> Solicitar membresia
418
                          </a>
419
                        )
420
                      }
421
                    </div>
422
                    {/* <?php echo $this->similarGroupsHelper($group_id) ?> */}
423
                    <SuggestedGroupsHelper groupId={groupId} />
424
                  </div>
425
                </div>
426
              </div>
427
            </div>
428
          </div>
429
        </div>
430
      </main>
431
    </React.Fragment>
432
  );
433
};
434
 
435
const mapDispatchToProps = {
436
  setTimelineUrl: (url) => setTimelineUrl(url),
437
  addNotification: (notification) => addNotification(notification),
438
};
439
 
440
 
441
export default connect(null, mapDispatchToProps)(View);