Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1759 | Rev 1761 | 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="">
269
                                  <img
270
                                    // src="<?php echo $this->basePath('images/ic1.png') ?>"
271
                                    src="/images/ic1.png"
272
                                    alt=""
273
                                  />
274
                                  <span>Publicaciones</span>
275
                                </a>
276
                              </li>
277
                              <li
278
                                className={`${
279
                                  currentTab === groupTabs.INFO_TAB ? "active" : ""
280
                                } animated fadeIn group-view-tab`}
281
                                onClick={(e) => {
282
                                  e.preventDefault();
283
                                  setCurrentTab(groupTabs.INFO_TAB);
284
                                   (groupTabs.INFO_TAB);
285
                                }}
286
                              >
287
                                <a href="#" title="">
288
                                  <img
289
                                    // src="<?php echo $this->basePath('images/ic2.png') ?>"
290
                                    src="/images/ic2.png"
291
                                    alt=""
292
                                  />
293
                                  <span className="ellipsis">Info. del grupo</span>
294
                                </a>
295
                              </li>
296
                            </ul>
297
                          </StyledTabWrapper>
298
                        )
299
                      }
300
                      {/* <!-- tab-feed end--> */}
301
                    </div>
302
                    {/* <!--user-tab-sec end--> */}
303
 
304
                    <div
305
                      className="product-feed-tab animated fadeIn"
306
                      id="feed-dd"
307
                      style={{
308
                        display:
309
                          currentTab === groupTabs.FEED_TAB ? "block" : "none",
310
                      }}
311
                    >
312
                      <div className="">
313
                        <ShareFeed
314
                          feedType={feedTypes.GROUP}
315
                          postUrl={`/feed/add/group/${groupId}`}
316
                        />
317
                      </div>
318
                      {/* <!--posts-section star--> */}
319
                      <div className="posts-section">
320
                        <FeedSection routeTimeline={routeTimeline} />
321
                      </div>
322
                      {/* <!--posts-section end--> */}
323
                    </div>
324
                    {/* <!--product-feed-tab end--> */}
325
 
326
                    <div
327
                      className="product-feed-tab  animated fadeIn"
328
                      id="info-dd"
329
                      style={{
330
                        display:
331
                          currentTab === groupTabs.INFO_TAB ? "block" : "none",
332
                      }}
333
                    >
334
                      <div className="main-ws-sec">
335
                        {/* <!--user-tab-sec start--> */}
336
                        {!!overview && (
337
                          <div className="user-profile-extended-ov">
338
                            <h3>Visión General</h3>
339
                            <span id="overview-description">
340
                              {parse(overview)}
341
                            </span>
342
                          </div>
343
                        )}
344
                        {/* <!--user-tab-sec endit--> */}
345
 
346
                        {/* <!--user-tab-sec start--> */}
347
                        {!!groupType && (
348
                          <div className="user-profile-extended-ov">
349
                            <h3>Tipo</h3>
350
                            <span id="overview-type">{groupType}</span>
351
                          </div>
352
                        )}
353
                        {/* <!--user-tab-sec endit--> */}
354
 
355
                        {/* <!--user-tab-sec start--> */}
356
                        {!!industry && (
357
                          <div className="user-profile-extended-ov">
358
                            <h3>Industria</h3>
359
                            <span id="overview-industry">{industry}</span>
360
                          </div>
361
                        )}
362
                        {/* <!--user-tab-sec endit--> */}
363
 
364
                        {/* <!--user-tab-sec start--> */}
365
                        {/* <?php if($privacy) : ?> */}
366
                        {!!privacy && (
367
                          <div className="user-profile-extended-ov">
368
                            <h3>Privacidad</h3>
369
                            <span id="overview-privacy">{privacy}</span>
370
                          </div>
371
                        )}
372
                        {/* <!--user-tab-sec endit--> */}
373
 
374
                        {/* <!--user-tab-sec start--> */}
375
                        {!!accessibility && (
376
                          <div className="user-profile-extended-ov">
377
                            <h3>Accesibilidad</h3>
378
                            <span id="overview-accessibility">
379
                              {accessibility}
380
                            </span>
381
                          </div>
382
                        )}
383
                        {/* <!--user-tab-sec endit--> */}
384
 
385
                        {/* <!--user-tab-sec start--> */}
386
                        {!!website && (
387
                          <div className="user-profile-extended-ov">
388
                            <h3>Página Web</h3>
389
                            <span id="overview-website">{website}</span>
390
                          </div>
391
                        )}
392
                        {/* <!--user-tab-sec endit--> */}
393
 
394
                        {/* <!--user-profile-ov end--> */}
395
                      </div>
396
                      {/* <!--main-ws-sec end--> */}
397
                    </div>
398
                  </div>
399
                </div>
400
                {/* <!--main-ws-sec end--> */}
401
 
402
                <div className="col-lg-3 d-sm-none d-none d-md-block d-lg-block">
403
                  <div className="right-sidebar">
404
                    <div className="message-btn">
1758 steven 405
 
1 www 406
                      {
407
                        actionLinks.link_accept && (
408
                          <a
409
                            href="#"
410
                            onClick={() => handleActionLink(actionLinks.link_accept)}
411
                            className="btn btn-success"
412
                            title=""
413
                          >
414
                            <i className="fa fa-check"></i> Aceptar invitacion
415
                          </a>
416
                        )
417
                      }
418
                      {
419
                        actionLinks.link_cancel && (
420
                          <a
421
                            href="#"
422
                            onClick={() => handleActionLink(actionLinks.link_cancel)}
423
                            className="btn btn-danger"
424
                            title=""
425
                          >
426
                            <i className="fa fa-close"></i> Cancelar invitacion
427
                          </a>
428
                        )
429
                      }
430
                      {
431
                        (!linkInvite && actionLinks.link_leave) && (
432
                          <a
433
                            href="#"
434
                            onClick={() => handleActionLink(actionLinks.link_leave)}
435
                            className="btn btn-danger"
436
                            title=""
437
                          >
438
                            <i className="fas fa-door-open"></i> Abandonar grupo
439
                          </a>
440
                        )
441
                      }
442
                      {
443
                        actionLinks.link_request && (
444
                          <a
445
                            href="#"
446
                            onClick={() => handleActionLink(actionLinks.link_request)}
447
                            className="btn btn-primary"
448
                            title=""
449
                          >
450
                            <i className="fa fa-plus"></i> Solicitar membresia
451
                          </a>
452
                        )
453
                      }
454
                    </div>
455
                    {/* <?php echo $this->similarGroupsHelper($group_id) ?> */}
456
                    <SuggestedGroupsHelper groupId={groupId} />
457
                  </div>
458
                </div>
459
              </div>
460
            </div>
461
          </div>
462
        </div>
463
      </main>
464
    </React.Fragment>
465
  );
466
};
467
 
468
const mapDispatchToProps = {
469
  setTimelineUrl: (url) => setTimelineUrl(url),
470
  addNotification: (notification) => addNotification(notification),
471
};
472
 
473
 
474
export default connect(null, mapDispatchToProps)(View);