Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2255 | Rev 2374 | 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('')
2246 stevensc 69
 
1 www 70
  setTimelineUrl(routeTimeline);
2246 stevensc 71
  const load = () => {
1 www 72
    axios.get('')
73
      .then(res => {
2246 stevensc 74
        if (res.data.success) {
1 www 75
          setActionLinks(res.data.data)
2246 stevensc 76
        } else {
1 www 77
          AddNotification({
78
            type: 'error',
79
            payload: res.data.data
80
          })
81
        }
82
      })
83
      .catch(err => {
84
        console.log('>>: err > ', err)
85
      })
86
  }
2246 stevensc 87
 
88
  React.useEffect(() => {
1 www 89
    load()
90
  }, [])
1068 stevensc 91
 
1 www 92
  const handleActionLink = (url) => {
93
    axios.post(url)
94
      .then(res => {
2246 stevensc 95
        if (res.data.success) {
1 www 96
          AddNotification({
97
            style: 'success',
98
            msg: res.data.data
99
          })
100
          window.location.reload()
2246 stevensc 101
        } else {
1 www 102
          AddNotification({
103
            style: 'error',
104
            msg: res.data.data
105
          })
106
        }
107
      })
108
      .catch(err => {
109
        console.log('>>: err > ', err)
110
      })
111
  }
2246 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]) ?>"
2246 stevensc 118
          src={`/storage/type/group-cover/code/${groupId}/${cover ? `filename/${cover}` : ""
119
            }`}
1 www 120
          alt="cover-image"
121
        />
122
      </section>
123
      <main>
124
        <div className="main-section">
1765 steven 125
          <div className="ph-5">
1 www 126
            <div className="main-section-data">
2372 stevensc 127
              <div className="main-left-sidebar border-radius border-gray overflow-hidden">
128
                <div className="user_profile m-0 p-1">
129
                  <div className="user-pro-img">
130
                    <img
131
                      // src="<?php echo $this->url('storage', ['type' => 'group', 'code' => $group_id_encrypted, 'filename' => $image]) ?>"
132
                      src={`/storage/type/group/code/${groupId}/${image ? `filename/${image}` : ""
133
                        }`}
134
                      alt="profile-image"
135
                    />
136
                  </div>
137
                  <div className="user_pro_status">
138
                    <h1 className="font-weight-bold" style={{ fontSize: '1.5rem' }} >{name}</h1>
139
                    <ul className="flw-status">
140
                      <div
141
                        className="container horizontal-list"
142
                      >
143
                        <div className="row ">
144
                          <div className="col">
145
                            <a
146
                              href={linkInmail || '#'}
147
                              className="btn btn-primary"
148
                              title=""
149
                            >
150
                              Mensaje
151
                            </a>
152
                          </div>
153
                          <div className="col">
154
                            <p>Miembros</p>
155
                            <b style={{ fontSize: '1rem' }} >{totalMembers}</b>
156
                          </div>
157
                          {
158
                            actionLinks.link_accept && (
1756 steven 159
                              <div className="col">
2372 stevensc 160
                                <button
161
                                  onClick={() => handleActionLink(actionLinks.link_accept)}
1759 steven 162
                                  className="btn btn-primary"
1758 steven 163
                                  title=""
164
                                >
2372 stevensc 165
                                  <span className="ellipsis">
166
                                    Aceptar invitacion
167
                                  </span>
168
                                </button>
1758 steven 169
                              </div>
2372 stevensc 170
                            )
171
                          }
172
                          {
173
                            actionLinks.link_cancel && (
2254 stevensc 174
                              <div className="col">
2372 stevensc 175
                                <button
176
                                  onClick={() => handleActionLink(actionLinks.link_cancel)}
177
                                  className="btn btn-primary"
178
                                  title=""
179
                                >
180
                                  <span className="ellipsis">
181
                                    Cancelar invitacion
182
                                  </span>
183
                                </button>
2254 stevensc 184
                              </div>
2372 stevensc 185
                            )
186
                          }
187
                          {
188
                            (!linkInvite && actionLinks.link_leave) && (
189
                              <div className="col">
190
                                <button
191
                                  onClick={() => handleActionLink(actionLinks.link_leave)}
192
                                  className="btn btn-primary"
193
                                  title=""
194
                                >
195
                                  <span className="ellipsis">
196
                                    Abandonar grupo
197
                                  </span>
198
                                </button>
199
                              </div>
200
                            )
201
                          }
202
                          {
203
                            actionLinks.link_request && (
204
                              <div className="col">
205
                                <button
206
                                  onClick={() => handleActionLink(actionLinks.link_request)}
207
                                  className="btn btn-primary"
208
                                  title=""
209
                                >
210
                                  Solicitar membresia
211
                                </button>
212
                              </div>
213
                            )
214
                          }
215
                        </div>
216
                      </div>
2246 stevensc 217
 
2372 stevensc 218
                    </ul>
1 www 219
                  </div>
220
                </div>
2372 stevensc 221
                <GroupMembersHelper groupId={groupId} handleFirstLinkInvite={link => setLinkInvite(link)} />
222
              </div>
223
              <div className="main-ws-sec">
224
                <div className="user-tab-sec">
225
                  {
226
                    !withoutFeeds && (
227
                      <div className="row">
228
                        <div className="col text-left pl-0">
229
                          <button
230
                            className={` ${currentTab === groupTabs.FEED_TAB ? "active" : ""
231
                              } animated fadeIn btn btn-link p-0 text-decoration-none`}
232
                            onClick={(e) => {
233
                              e.preventDefault();
234
                              setCurrentTab(groupTabs.FEED_TAB);
1 www 235
 
2372 stevensc 236
                            }}
237
                          >
238
                            <span className="ellipsis text-dark font-weight-bold">Ver Publicaciones</span>
239
                          </button>
240
                        </div>
241
                        <div className="col text-right pl-0">
242
                          <button
243
                            className={` ${currentTab === groupTabs.INFO_TAB ? "active" : ""
244
                              } animated fadeIn btn btn-link p-0 text-decoration-none`}
245
                            onClick={(e) => {
246
                              e.preventDefault();
247
                              setCurrentTab(groupTabs.INFO_TAB);
248
                            }}
249
                          >
250
                            <span className="ellipsis text-dark font-weight-bold">Ver Información</span>
251
                          </button>
252
                        </div>
253
                      </div>
254
                    )
255
                  }
256
                  {/* <!-- tab-feed end--> */}
257
                </div>
258
                {/* <!--user-tab-sec end--> */}
2246 stevensc 259
 
2372 stevensc 260
                <div
261
                  className="product-feed-tab animated fadeIn"
262
                  id="feed-dd"
263
                  style={{
264
                    display:
265
                      currentTab === groupTabs.FEED_TAB ? "block" : "none",
266
                  }}
267
                >
268
                  <ShareFeed
269
                    feedType={feedTypes.GROUP}
270
                    postUrl={`/feed/add/group/${groupId}`}
271
                  />
272
                  {/* <!--posts-section star--> */}
273
                  <div className="posts-section">
274
                    <FeedSection routeTimeline={routeTimeline} />
1 www 275
                  </div>
2372 stevensc 276
                  {/* <!--posts-section end--> */}
277
                </div>
278
                {/* <!--product-feed-tab end--> */}
279
 
280
                <div
281
                  className="product-feed-tab  animated fadeIn"
282
                  id="info-dd"
283
                  style={{
284
                    display:
285
                      currentTab === groupTabs.INFO_TAB ? "block" : "none",
286
                  }}
287
                >
1 www 288
                  <div className="main-ws-sec">
2372 stevensc 289
                    {/* <!--user-tab-sec start--> */}
290
                    {!!overview && (
291
                      <div className="user-profile-extended-ov">
292
                        <h3>Visión General</h3>
293
                        <span id="overview-description">
294
                          {parse(overview)}
295
                        </span>
296
                      </div>
297
                    )}
298
                    {/* <!--user-tab-sec endit--> */}
2246 stevensc 299
 
2372 stevensc 300
                    {/* <!--user-tab-sec start--> */}
301
                    {!!groupType && (
302
                      <div className="user-profile-extended-ov">
303
                        <h3>Tipo</h3>
304
                        <span id="overview-type">{groupType}</span>
305
                      </div>
306
                    )}
307
                    {/* <!--user-tab-sec endit--> */}
1 www 308
 
2372 stevensc 309
                    {/* <!--user-tab-sec start--> */}
310
                    {!!industry && (
311
                      <div className="user-profile-extended-ov">
312
                        <h3>Industria</h3>
313
                        <span id="overview-industry">{industry}</span>
1 www 314
                      </div>
2372 stevensc 315
                    )}
316
                    {/* <!--user-tab-sec endit--> */}
1 www 317
 
2372 stevensc 318
                    {/* <!--user-tab-sec start--> */}
319
                    {/* <?php if($privacy) : ?> */}
320
                    {!!privacy && (
321
                      <div className="user-profile-extended-ov">
322
                        <h3>Privacidad</h3>
323
                        <span id="overview-privacy">{privacy}</span>
324
                      </div>
325
                    )}
326
                    {/* <!--user-tab-sec endit--> */}
1 www 327
 
2372 stevensc 328
                    {/* <!--user-tab-sec start--> */}
329
                    {!!accessibility && (
330
                      <div className="user-profile-extended-ov">
331
                        <h3>Accesibilidad</h3>
332
                        <span id="overview-accessibility">
333
                          {accessibility}
334
                        </span>
335
                      </div>
336
                    )}
337
                    {/* <!--user-tab-sec endit--> */}
1 www 338
 
2372 stevensc 339
                    {/* <!--user-tab-sec start--> */}
340
                    {!!website && (
341
                      <div className="user-profile-extended-ov">
342
                        <h3>Página Web</h3>
343
                        <span id="overview-website">{website}</span>
344
                      </div>
345
                    )}
346
                    {/* <!--user-tab-sec endit--> */}
1 www 347
 
2372 stevensc 348
                    {/* <!--user-profile-ov end--> */}
1 www 349
                  </div>
2372 stevensc 350
                  {/* <!--main-ws-sec end--> */}
1 www 351
                </div>
352
              </div>
2372 stevensc 353
              <SuggestedGroupsHelper groupId={groupId} />
1 www 354
            </div>
355
          </div>
356
        </div>
357
      </main>
358
    </React.Fragment>
359
  );
360
};
361
 
362
const mapDispatchToProps = {
363
  setTimelineUrl: (url) => setTimelineUrl(url),
364
  addNotification: (notification) => addNotification(notification),
365
};
366
 
367
 
368
export default connect(null, mapDispatchToProps)(View);