Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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