Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1761 | Rev 1763 | 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">
1756 steven 144
                          <div
145
                            className="container horizontal-list"
146
                          >
147
                            <div
148
                              className="row "
149
                            >
150
                              <div className="col">
1757 steven 151
                                <p>Miembros</p>
152
                                <b style={{fontSize: '1rem'}} >{totalMembers}</b>
153
                              </div>
154
                              <div className="col">
1756 steven 155
                                <a
156
                                  href={linkInmail || '#'}
1759 steven 157
                                  className="btn btn-primary"
1758 steven 158
                                  title=""
159
                                >
1760 steven 160
                                  Mensaje
1758 steven 161
                                </a>
162
                              </div>
163
                              <div className="col">
164
                                <a
165
                                  href={linkInmail || '#'}
1756 steven 166
                                  className="btn btn-primary"
167
                                  title=""
168
                                >
169
                                  Mensaje
170
                                </a>
171
                              </div>
172
                              {
173
                                actionLinks.link_accept && (
174
                                  <div
175
                                    className="col"
176
                                  >
177
                                    <button
178
                                      onClick={() => handleActionLink(actionLinks.link_accept)}
179
                                      className="btn btn-primary"
180
                                      title=""
181
                                    >
182
                                      <span className="ellipsis">
183
                                        Aceptar invitacion
184
                                      </span>
185
                                    </button>
186
                                  </div>
187
                                )
188
                              }
189
                              {
190
                                actionLinks.link_cancel && (
191
                                  <div
192
                                    className="col"
193
                                  >
194
                                    <button
195
                                      onClick={() => handleActionLink(actionLinks.link_cancel)}
196
                                      className="btn btn-primary"
197
                                      title=""
198
                                    >
199
                                      <span className="ellipsis">
200
                                        Cancelar invitacion
201
                                      </span>
202
                                    </button>
203
                                  </div>
204
                                )
205
                              }
206
                              {
207
                                (!linkInvite && actionLinks.link_leave) && (
208
                                  <div
209
                                    className="col"
210
                                  >
211
                                    <button
212
                                      onClick={() => handleActionLink(actionLinks.link_leave)}
213
                                      className="btn btn-danger"
214
                                      title=""
215
                                    >
216
                                      <span className="ellipsis">
217
                                        Abandonar grupo
218
                                      </span>
219
                                    </button>
220
                                  </div>
221
                                )
222
                              }
223
                              {
224
                                actionLinks.link_request && (
225
                                  <div
226
                                    className="col"
227
                                  >
228
                                    <button
229
                                      onClick={() => handleActionLink(actionLinks.link_request)}
230
                                      className="btn btn-primary"
231
                                      title=""
232
                                    >
233
                                      Solicitar membresia
234
                                    </button>
235
                                  </div>
236
                                )
237
                              }
238
                            </div>
239
                          </div>
240
 
1 www 241
                        </ul>
242
                      </div>
243
                    </div>
244
                  </div>
245
                  <GroupMembersHelper groupId={groupId} handleFirstLinkInvite={link => setLinkInvite(link)} />
246
                </div>
247
 
248
                <div className="col-lg-6">
249
                  <div className="message-btn d-block d-md-none d-lg-none d-sm-none">
1756 steven 250
 
1 www 251
                  </div>
252
                  <div className="main-ws-sec">
253
                    <div className="user-tab-sec">
254
                      {
255
                        !withoutFeeds && (
256
                          <StyledTabWrapper>
257
                            <ul>
258
                              <li
259
                                className={` ${
260
                                  currentTab === groupTabs.FEED_TAB ? "active" : ""
261
                                } animated fadeIn`}
262
                                onClick={(e) => {
263
                                  e.preventDefault();
264
                                  setCurrentTab(groupTabs.FEED_TAB);
265
                                   (groupTabs.FEED_TAB);
266
                                }}
267
                              >
268
                                <a href="#" title="">
1762 steven 269
                                  <span className="ellipsis text-dark">Ver Publicaciones</span>
1 www 270
                                </a>
271
                              </li>
272
                              <li
273
                                className={`${
274
                                  currentTab === groupTabs.INFO_TAB ? "active" : ""
275
                                } animated fadeIn group-view-tab`}
276
                                onClick={(e) => {
277
                                  e.preventDefault();
278
                                  setCurrentTab(groupTabs.INFO_TAB);
279
                                   (groupTabs.INFO_TAB);
280
                                }}
281
                              >
282
                                <a href="#" title="">
1762 steven 283
                                  <span className="ellipsis text-dark">Ver Información</span>
1 www 284
                                </a>
285
                              </li>
286
                            </ul>
287
                          </StyledTabWrapper>
288
                        )
289
                      }
290
                      {/* <!-- tab-feed end--> */}
291
                    </div>
292
                    {/* <!--user-tab-sec end--> */}
293
 
294
                    <div
295
                      className="product-feed-tab animated fadeIn"
296
                      id="feed-dd"
297
                      style={{
298
                        display:
299
                          currentTab === groupTabs.FEED_TAB ? "block" : "none",
300
                      }}
301
                    >
302
                      <div className="">
303
                        <ShareFeed
304
                          feedType={feedTypes.GROUP}
305
                          postUrl={`/feed/add/group/${groupId}`}
306
                        />
307
                      </div>
308
                      {/* <!--posts-section star--> */}
309
                      <div className="posts-section">
310
                        <FeedSection routeTimeline={routeTimeline} />
311
                      </div>
312
                      {/* <!--posts-section end--> */}
313
                    </div>
314
                    {/* <!--product-feed-tab end--> */}
315
 
316
                    <div
317
                      className="product-feed-tab  animated fadeIn"
318
                      id="info-dd"
319
                      style={{
320
                        display:
321
                          currentTab === groupTabs.INFO_TAB ? "block" : "none",
322
                      }}
323
                    >
324
                      <div className="main-ws-sec">
325
                        {/* <!--user-tab-sec start--> */}
326
                        {!!overview && (
327
                          <div className="user-profile-extended-ov">
328
                            <h3>Visión General</h3>
329
                            <span id="overview-description">
330
                              {parse(overview)}
331
                            </span>
332
                          </div>
333
                        )}
334
                        {/* <!--user-tab-sec endit--> */}
335
 
336
                        {/* <!--user-tab-sec start--> */}
337
                        {!!groupType && (
338
                          <div className="user-profile-extended-ov">
339
                            <h3>Tipo</h3>
340
                            <span id="overview-type">{groupType}</span>
341
                          </div>
342
                        )}
343
                        {/* <!--user-tab-sec endit--> */}
344
 
345
                        {/* <!--user-tab-sec start--> */}
346
                        {!!industry && (
347
                          <div className="user-profile-extended-ov">
348
                            <h3>Industria</h3>
349
                            <span id="overview-industry">{industry}</span>
350
                          </div>
351
                        )}
352
                        {/* <!--user-tab-sec endit--> */}
353
 
354
                        {/* <!--user-tab-sec start--> */}
355
                        {/* <?php if($privacy) : ?> */}
356
                        {!!privacy && (
357
                          <div className="user-profile-extended-ov">
358
                            <h3>Privacidad</h3>
359
                            <span id="overview-privacy">{privacy}</span>
360
                          </div>
361
                        )}
362
                        {/* <!--user-tab-sec endit--> */}
363
 
364
                        {/* <!--user-tab-sec start--> */}
365
                        {!!accessibility && (
366
                          <div className="user-profile-extended-ov">
367
                            <h3>Accesibilidad</h3>
368
                            <span id="overview-accessibility">
369
                              {accessibility}
370
                            </span>
371
                          </div>
372
                        )}
373
                        {/* <!--user-tab-sec endit--> */}
374
 
375
                        {/* <!--user-tab-sec start--> */}
376
                        {!!website && (
377
                          <div className="user-profile-extended-ov">
378
                            <h3>Página Web</h3>
379
                            <span id="overview-website">{website}</span>
380
                          </div>
381
                        )}
382
                        {/* <!--user-tab-sec endit--> */}
383
 
384
                        {/* <!--user-profile-ov end--> */}
385
                      </div>
386
                      {/* <!--main-ws-sec end--> */}
387
                    </div>
388
                  </div>
389
                </div>
390
                {/* <!--main-ws-sec end--> */}
391
 
392
                <div className="col-lg-3 d-sm-none d-none d-md-block d-lg-block">
393
                  <div className="right-sidebar">
394
                    <div className="message-btn">
1758 steven 395
 
1 www 396
                      {
397
                        actionLinks.link_accept && (
398
                          <a
399
                            href="#"
400
                            onClick={() => handleActionLink(actionLinks.link_accept)}
401
                            className="btn btn-success"
402
                            title=""
403
                          >
404
                            <i className="fa fa-check"></i> Aceptar invitacion
405
                          </a>
406
                        )
407
                      }
408
                      {
409
                        actionLinks.link_cancel && (
410
                          <a
411
                            href="#"
412
                            onClick={() => handleActionLink(actionLinks.link_cancel)}
413
                            className="btn btn-danger"
414
                            title=""
415
                          >
416
                            <i className="fa fa-close"></i> Cancelar invitacion
417
                          </a>
418
                        )
419
                      }
420
                      {
421
                        (!linkInvite && actionLinks.link_leave) && (
422
                          <a
423
                            href="#"
424
                            onClick={() => handleActionLink(actionLinks.link_leave)}
425
                            className="btn btn-danger"
426
                            title=""
427
                          >
428
                            <i className="fas fa-door-open"></i> Abandonar grupo
429
                          </a>
430
                        )
431
                      }
432
                      {
433
                        actionLinks.link_request && (
434
                          <a
435
                            href="#"
436
                            onClick={() => handleActionLink(actionLinks.link_request)}
437
                            className="btn btn-primary"
438
                            title=""
439
                          >
440
                            <i className="fa fa-plus"></i> Solicitar membresia
441
                          </a>
442
                        )
443
                      }
444
                    </div>
445
                    {/* <?php echo $this->similarGroupsHelper($group_id) ?> */}
446
                    <SuggestedGroupsHelper groupId={groupId} />
447
                  </div>
448
                </div>
449
              </div>
450
            </div>
451
          </div>
452
        </div>
453
      </main>
454
    </React.Fragment>
455
  );
456
};
457
 
458
const mapDispatchToProps = {
459
  setTimelineUrl: (url) => setTimelineUrl(url),
460
  addNotification: (notification) => addNotification(notification),
461
};
462
 
463
 
464
export default connect(null, mapDispatchToProps)(View);