Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3814 | Rev 5070 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3814 Rev 3816
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useState } from "react";
2
import React, { useState } from "react";
3
import { axios } from "../utils";
-
 
4
import { addNotification } from "../redux/notification/notification.actions";
3
import { addNotification } from "../redux/notification/notification.actions";
5
import ConfirmationBox from "../shared/confirmation-box/ConfirmationBox";
4
import ConfirmationBox from "../shared/confirmation-box/ConfirmationBox";
6
import Spinner from "../shared/loading-spinner/Spinner";
5
import Spinner from "../shared/loading-spinner/Spinner";
-
 
6
import { axios } from "../utils";
7
import styled from 'styled-components'
7
import styled from 'styled-components'
Línea 8... Línea 8...
8
 
8
 
9
const StyledSpinnerContainer = styled.div`
9
const StyledSpinnerContainer = styled.div`
10
  position: absolute;
10
  position: absolute;
Línea 16... Línea 16...
16
  display: flex;
16
  display: flex;
17
  justify-content: center;
17
  justify-content: center;
18
  align-items: center;
18
  align-items: center;
19
  z-index: 300;
19
  z-index: 300;
20
`;
20
`;
21
 
-
 
22
 
-
 
23
const Profile = ({
21
const Profile = (props) => {
-
 
22
  // props destructuring
-
 
23
  const {
24
  image,
24
    image,
25
  name,
25
    name,
26
  email,
26
    email,
27
  network,
27
    network,
28
  status,
28
    status,
29
  link_view,
29
    link_view,
30
  link_edit,
30
    link_edit,
31
  link_delete,
31
    link_delete,
32
  link_cancel,
32
    link_cancel,
33
  link_block,
33
    link_block,
34
  link_reject,
34
    link_reject,
35
  link_accept,
35
    link_accept,
36
  link_inmail,
36
    link_inmail,
37
  link_request,
37
    link_request,
38
  link_unblock,
38
    link_unblock,
39
  link_unfollow,
39
    link_unfollow,
40
  link_approve,
40
    link_approve,
41
  link_leave,
41
    link_leave,
42
  link_admin,
42
    link_admin,
43
  link_impersonate,
43
    link_impersonate,
44
  fetchCallback,
44
    fetchCallback,
45
  isTopData = false,
45
    isTopData = false,
46
  btnAcceptTitle = 'Ver perfil',
46
    btnAcceptTitle = 'Ver perfil',
47
  btnCancelTitle = 'Borrar perfil',
47
    btnCancelTitle = 'Borrar perfil',
48
  btnEditTitle = 'Editar perfil'
48
    btnEditTitle = 'Editar perfil'
49
}) => {
49
  } = props;
Línea 50... Línea 50...
50
 
50
 
51
  const getImpersonateUrl = async (url = '') => {
51
  const getImpersonateUrl = async (url = '') => {
52
    try {
52
    try {
53
      const { data } = await axios.get(url)
53
      const { data } = await axios.get(url)
54
      if (data.success) window.location.href = data.data;
54
      if (data.success) window.location.href = data.data;
55
    } catch (error) {
55
    } catch (error) {
56
      console.log('>>: error > ', error)
56
      console.log('>>: error > ', error)
57
    }
57
    }
Línea -... Línea 58...
-
 
58
  }
58
  }
59
 
-
 
60
  // states
59
 
61
  const [showConfirmationBox, setShowConfirmationBox] = useState(false);
60
  const [showConfirmationBox, setShowConfirmationBox] = useState(null)
-
 
-
 
62
  const [showCancelConfirmationBox, setShowCancelConfirmationBox] = useState(false);
-
 
63
  const [showBlockConfirmationBox, setShowBlockConfirmationBox] = useState(false);
-
 
64
  const [showRejectConfirmationBox, setShowRejectConfirmationBox] = useState(false);
-
 
65
  const [showApproveConfirmationBox, setShowApproveConfirmationBox] = useState(false);
61
  const [loading, setLoading] = useState(false)
66
  const [showRequestConfirmationBox, setShowRequestConfirmationBox] = useState(false);
Línea 62... Línea 67...
62
 
67
  const [showUnblockConfirmationBox, setShowUnblockConfirmationBox] = useState(false);
-
 
68
  const [showLeaveConfirmationBox, setShowLeaveConfirmationBox] = useState(false);
63
  const handleShowConfirmation = (type) => setShowConfirmationBox(type)
69
 
64
 
70
  const [loading, setLoading] = useState(false)
65
  const linkOptions = {
71
  const handleShowConfirmationBox = (show = !showConfirmationBox) => {
66
    view: link_view,
72
    setShowConfirmationBox(show);
-
 
73
  };
-
 
74
  const handleCancelConfirmationBox = (show = !showConfirmationBox) => {
67
    edit: link_edit,
75
    setShowCancelConfirmationBox(show);
-
 
76
  };
-
 
77
  const handleBlockConfirmationBox = (show = !showConfirmationBox) => {
68
    delete: link_delete,
78
    setShowBlockConfirmationBox(show);
-
 
79
  };
69
    cancel: link_cancel,
80
  const handleRejectConfirmationBox = (show = !showConfirmationBox) => {
70
    block: link_block,
81
    setShowRejectConfirmationBox(show);
-
 
82
  };
71
    reject: link_reject,
83
  const handleApproveConfirmationBox = (show = !showConfirmationBox) => {
72
    accept: link_accept,
84
    setShowApproveConfirmationBox(show);
-
 
85
  };
73
    inmail: link_inmail,
86
  const handleRequestConfirmationBox = (show = !showConfirmationBox) => {
74
    request: link_request,
87
    setShowRequestConfirmationBox(show);
-
 
88
  };
75
    unblock: link_unblock,
89
  const handleUnblockConfirmationBox = (show = !showConfirmationBox) => {
76
    unfollow: link_unfollow,
90
    setShowUnblockConfirmationBox(show);
77
    approve: link_approve,
91
  };
Línea 78... Línea 92...
78
    leave: link_leave,
92
  const handleLeaveConfirmationBox = (show = !showConfirmationBox) => {
79
    admin: link_admin,
93
    setShowLeaveConfirmationBox(show);
80
  }
94
  };
81
 
95
 
Línea 129... Línea 143...
129
  }
143
  }
Línea 130... Línea 144...
130
 
144
 
131
  return (
145
  return (
132
    <div className='profile_info'>
146
    <div className='profile_info'>
133
      <div className={`${image ? 'd-flex' : 'd-block'} position-relative`}>
147
      <div className={`${image ? 'd-flex' : 'd-block'} position-relative`}>
134
        {image &&
148
        {!!image &&
135
          <div className='profile_info_header_imgContainer'>
149
          <div className='profile_info_header_imgContainer'>
136
            <img src={image} className="object-fit-contain" style={{ maxHeight: '100px' }} alt="group image" />
150
            <img src={image} className="object-fit-contain" style={{ maxHeight: '100px' }} alt="group image" />
137
          </div>
151
          </div>
138
        }
152
        }
Línea 149... Línea 163...
149
          {network &&
163
          {network &&
150
            <h4 className={`${status ? '' : "w-100 text-left"} ${isTopData ? 'mb-2' : ''} w-100`}>
164
            <h4 className={`${status ? '' : "w-100 text-left"} ${isTopData ? 'mb-2' : ''} w-100`}>
151
              {network}
165
              {network}
152
            </h4>
166
            </h4>
153
          }
167
          }
-
 
168
          {
154
          {isTopData &&
169
            isTopData
-
 
170
            &&
155
            <ul>
171
            <ul>
156
              {link_view &&
172
              {link_view &&
157
                <li>
173
                <li>
158
                  <a
174
                  <a
159
                    href={link_view}
175
                    href={link_view}
-
 
176
                    data-link={link_view}
160
                    className="btn btn-primary ellipsis"
177
                    className="btn btn-secondary ellipsis"
161
                  >
178
                  >
162
                    {btnAcceptTitle}
179
                    {btnAcceptTitle}
163
                  </a>
180
                  </a>
164
                </li>
181
                </li>
165
              }
182
              }
166
              {link_inmail &&
183
              {link_inmail &&
167
                <li>
184
                <li>
168
                  <a
185
                  <a
169
                    href={link_inmail}
186
                    href={link_inmail}
-
 
187
                    data-link={link_inmail}
170
                    className="btn btn-secondary"
188
                    className="btn btn-primary"
171
                  >
189
                  >
172
                    Mensaje
190
                    Mensaje
173
                  </a>
191
                  </a>
174
                </li>
192
                </li>
175
              }
193
              }
Línea 182... Línea 200...
182
          </h4>
200
          </h4>
183
        }
201
        }
184
      </div>
202
      </div>
185
      <hr />
203
      <hr />
186
      <ul>
204
      <ul>
-
 
205
        {
187
        {(link_view && !isTopData) &&
206
          link_view && !isTopData && (
-
 
207
            <li>
-
 
208
              <a
-
 
209
                href={link_view}
-
 
210
                data-link={link_view}
-
 
211
                title=""
-
 
212
                className="btn btn-secondary"
-
 
213
              >
-
 
214
                {btnAcceptTitle}
-
 
215
              </a>
-
 
216
            </li>
-
 
217
          )
-
 
218
        }
-
 
219
        {
-
 
220
          link_edit && (
-
 
221
            <li>
-
 
222
              <a
-
 
223
                href={link_edit}
-
 
224
                data-link={link_edit}
-
 
225
                title=""
-
 
226
                className="btn btn-tertiary"
-
 
227
              >
-
 
228
                {btnEditTitle}
-
 
229
              </a>
-
 
230
            </li>
-
 
231
          )
-
 
232
        }
-
 
233
        {
-
 
234
          link_approve
-
 
235
          &&
188
          <li>
236
          <li>
189
            <a
237
            <a
190
              href={link_view}
238
              href="#"
191
              className="btn btn-tertiary"
239
              className="btn btn-tertiary"
-
 
240
              onClick={(e) => {
-
 
241
                e.preventDefault();
-
 
242
                handleApproveConfirmationBox();
-
 
243
              }}
192
            >
244
            >
193
              {btnAcceptTitle}
245
              Aprobar
194
            </a>
246
            </a>
195
          </li>
247
          </li>
196
        }
248
        }
-
 
249
        {
197
        {link_edit &&
250
          link_accept
-
 
251
          &&
198
          <li>
252
          <li>
199
            <a
253
            <a
200
              href={link_edit}
-
 
201
              data-link={link_edit}
-
 
202
              title=""
254
              href="#"
203
              className="btn btn-tertiary"
-
 
204
            >
-
 
205
              {btnEditTitle}
-
 
206
            </a>
-
 
207
          </li>
-
 
208
        }
-
 
209
        {link_approve &&
-
 
210
          <li>
-
 
211
            <button
-
 
212
              className="btn btn-tertiary"
255
              className="btn btn-tertiary"
213
              onClick={() => handleShowConfirmation('aprove')}
256
              onClick={(e) => {
214
            >
-
 
215
              Aprobar
257
                e.preventDefault();
216
            </button>
258
                handleApproveConfirmationBox();
217
          </li>
259
              }}
218
        }
-
 
219
        {link_accept &&
-
 
220
          <li>
-
 
221
            <button
-
 
222
              className="btn btn-tertiary"
-
 
223
              onClick={() => handleShowConfirmation('accept')}
-
 
224
            >
260
            >
225
              Aceptar
261
              Aceptar
226
            </button>
262
            </a>
227
          </li>
263
          </li>
228
        }
264
        }
-
 
265
        {
229
        {link_reject &&
266
          link_reject &&
230
          <li>
267
          <li>
231
            <button
268
            <a
-
 
269
              href="#"
232
              className="btn btn-tertiary"
270
              className="btn btn-primary"
-
 
271
              onClick={(e) => {
-
 
272
                e.preventDefault();
233
              onClick={() => handleShowConfirmation('reject')}
273
                handleRejectConfirmationBox();
-
 
274
              }}
234
            >
275
            >
235
              Rechazar
276
              Rechazar
236
            </button>
277
            </a>
237
          </li >
278
          </li>
238
        }
279
        }
-
 
280
        {
239
        {link_delete &&
281
          link_delete &&
240
          <li>
282
          <li>
241
            <button
283
            <a
-
 
284
              href="#"
242
              className="btn btn-tertiary"
285
              className="btn btn-primary"
-
 
286
              onClick={(e) => {
-
 
287
                e.preventDefault();
243
              onClick={() => handleShowConfirmation('delete')}
288
                handleShowConfirmationBox();
-
 
289
              }}
244
            >
290
            >
245
              {btnCancelTitle}
291
              {btnCancelTitle}
246
            </button>
292
            </a>
247
          </li >
293
          </li>
248
        }
294
        }
-
 
295
        {
249
        {(link_inmail && !isTopData) &&
296
          link_inmail && !isTopData
-
 
297
          &&
250
          <li>
298
          <li>
251
            <a
299
            <a
252
              href={link_inmail}
300
              href={link_inmail}
-
 
301
              data-link={link_inmail}
-
 
302
              title=""
253
              className="btn btn-secondary"
303
              className="btn btn-primary"
254
            >
304
            >
255
              Mensaje
305
              Mensaje
256
            </a>
306
            </a>
257
          </li>
307
          </li>
258
        }
308
        }
-
 
309
        {
259
        {link_admin &&
310
          link_admin &&
260
          <li>
311
          <li>
261
            <a
312
            <a
262
              onClick={() => getManageUrl()}
313
              onClick={() => getManageUrl()}
263
              data-link={link_admin}
314
              data-link={link_admin}
264
              title="Administrar empresa"
315
              title="Administrar empresa"
265
              className="btn btn-secondary"
316
              className="btn btn-primary"
266
            >
317
            >
267
              Administrar
318
              Administrar
268
            </a>
319
            </a>
269
          </li>
320
          </li>
270
        }
321
        }
-
 
322
        {
271
        {link_unfollow &&
323
          link_unfollow
-
 
324
          &&
272
          <li>
325
          <li>
273
            <a
326
            <a
274
              onClick={() => handleUnfollow(link_unfollow)}
327
              onClick={() => handleUnfollow(link_unfollow)}
275
              data-link={link_unfollow}
328
              data-link={link_unfollow}
276
              title="Administrar empresa"
329
              title="Administrar empresa"
277
              className="btn btn-secondary"
330
              className="btn btn-primary"
278
            >
331
            >
279
              Dejar de seguir
332
              Dejar de seguir
280
            </a>
333
            </a>
281
          </li>
334
          </li>
282
        }
335
        }
Línea -... Línea 336...
-
 
336
 
283
 
337
        {
284
        {link_block &&
338
          link_block &&
285
          <li>
339
          <li>
-
 
340
            <a
286
            <button
341
              href="#"
-
 
342
              className="btn btn-primary"
-
 
343
              onClick={(e) => {
287
              className="btn btn-tertiary"
344
                e.preventDefault();
-
 
345
                handleBlockConfirmationBox();
288
              onClick={() => handleShowConfirmation('block')}
346
              }}
289
            >
347
            >
290
              Bloquear
-
 
291
            </button>
-
 
292
          </li >
-
 
293
        }
-
 
294
        {link_unblock &&
-
 
295
          <li>
-
 
296
            <button
-
 
297
              className="btn btn-tertiary"
-
 
298
              onClick={() => handleShowConfirmation('unblock')}
348
              Bloquear
299
            >
-
 
300
              Desbloquear
-
 
301
            </button>
349
            </a>
302
          </li>
350
          </li>
-
 
351
        }
-
 
352
        {
-
 
353
          link_unblock && (
-
 
354
            <li>
-
 
355
              <a
-
 
356
                href="#"
-
 
357
                className="btn btn-tertiary"
-
 
358
                onClick={(e) => {
-
 
359
                  e.preventDefault();
-
 
360
                  handleUnblockConfirmationBox();
-
 
361
                }}
-
 
362
              >
-
 
363
                Desbloquear
-
 
364
              </a>
-
 
365
            </li>
-
 
366
          )
-
 
367
        }
303
        }
368
        {
-
 
369
          link_request
304
        {link_request &&
370
          &&
305
          <li>
371
          <li>
-
 
372
            <a
306
            <button
373
              href="#"
-
 
374
              className="btn btn-tertiary"
-
 
375
              onClick={(e) => {
307
              className="btn btn-tertiary"
376
                e.preventDefault();
-
 
377
                handleRequestConfirmationBox();
308
              onClick={() => handleShowConfirmation('request')}
378
              }}
309
            >
379
            >
310
              Conectar
380
              Conectar
311
            </button>
381
            </a>
312
          </li >
382
          </li>
-
 
383
        }
313
        }
384
        {
-
 
385
          link_cancel
314
        {link_cancel &&
386
          &&
315
          <li>
387
          <li>
-
 
388
            <a
316
            <button
389
              href="#"
-
 
390
              className="btn btn-primary"
-
 
391
              onClick={(e) => {
317
              className="btn btn-tertiary"
392
                e.preventDefault();
-
 
393
                handleCancelConfirmationBox();
318
              onClick={() => handleShowConfirmation('cancel')}
394
              }}
319
            >
395
            >
320
              Cancelar
396
              Cancelar
321
            </button>
397
            </a>
322
          </li >
398
          </li>
-
 
399
        }
323
        }
400
        {
324
        {link_leave &&
401
          link_leave &&
325
          <li>
402
          <li>
-
 
403
            <a
326
            <button
404
              href="#"
-
 
405
              className="btn btn-tertiary"
-
 
406
              onClick={(e) => {
327
              className="btn btn-tertiary"
407
                e.preventDefault();
-
 
408
                handleLeaveConfirmationBox();
328
              onClick={() => handleShowConfirmation('leave')}
409
              }}
329
            >
410
            >
330
              Abandonar
411
              Abandonar
331
            </button>
412
            </a>
332
          </li >
413
          </li>
333
        }
414
        }
-
 
415
      </ul>
334
      </ul >
416
      {
335
      {link_delete &&
417
        link_delete &&
336
        <div style={{ position: "relative" }}>
418
        <div style={{ position: "relative" }}>
337
          <ConfirmationBox
419
          <ConfirmationBox
338
            show={showConfirmationBox}
420
            show={showConfirmationBox}
339
            onClose={() => handleShowConfirmation(null)}
421
            onClose={() => handleShowConfirmationBox(false)}
340
            onAccept={() => handleCancelApply(linkOptions[showConfirmationBox])}
422
            onAccept={() => handleCancelApply(link_delete)}
341
          />
423
          />
342
        </div>
424
        </div>
-
 
425
      }
-
 
426
      {
-
 
427
        link_cancel && (
-
 
428
          <div style={{ position: "relative" }}>
-
 
429
            <ConfirmationBox
-
 
430
              show={showCancelConfirmationBox}
-
 
431
              onClose={() => handleCancelConfirmationBox(false)}
-
 
432
              onAccept={() => handleCancelApply(link_cancel)}
-
 
433
            />
-
 
434
          </div>
-
 
435
        )
-
 
436
      }
-
 
437
      {
-
 
438
        link_block && (
-
 
439
          <div style={{ position: "relative" }}>
-
 
440
            <ConfirmationBox
-
 
441
              show={showBlockConfirmationBox}
-
 
442
              onClose={() => handleBlockConfirmationBox(false)}
-
 
443
              onAccept={() => handleCancelApply(link_block)}
-
 
444
            />
-
 
445
          </div>
-
 
446
        )
-
 
447
      }
-
 
448
      {
-
 
449
        link_accept && (
-
 
450
          <div style={{ position: "relative" }}>
-
 
451
            <ConfirmationBox
-
 
452
              show={showApproveConfirmationBox}
-
 
453
              onClose={() => handleApproveConfirmationBox(false)}
-
 
454
              onAccept={() => handleCancelApply(link_accept)}
-
 
455
            />
-
 
456
          </div>
-
 
457
        )
-
 
458
      }
-
 
459
      {
-
 
460
        link_approve && (
-
 
461
          <div style={{ position: "relative" }}>
-
 
462
            <ConfirmationBox
-
 
463
              show={showApproveConfirmationBox}
-
 
464
              onClose={() => handleApproveConfirmationBox(false)}
-
 
465
              onAccept={() => handleCancelApply(link_approve)}
-
 
466
            />
-
 
467
          </div>
-
 
468
        )
-
 
469
      }
-
 
470
      {
-
 
471
        link_reject && (
-
 
472
          <div style={{ position: "relative" }}>
-
 
473
            <ConfirmationBox
-
 
474
              show={showRejectConfirmationBox}
-
 
475
              onClose={() => handleRejectConfirmationBox(false)}
-
 
476
              onAccept={() => handleCancelApply(link_reject)}
-
 
477
            />
-
 
478
          </div>
-
 
479
        )
-
 
480
      }
-
 
481
      {
-
 
482
        link_request && (
-
 
483
          <div style={{ position: "relative" }}>
-
 
484
            <ConfirmationBox
-
 
485
              show={showRequestConfirmationBox}
-
 
486
              onClose={() => handleRequestConfirmationBox(false)}
-
 
487
              onAccept={() => handleCancelApply(link_request)}
-
 
488
            />
-
 
489
          </div>
-
 
490
        )
-
 
491
      }
-
 
492
      {
-
 
493
        link_unblock && (
-
 
494
          <div style={{ position: "relative" }}>
-
 
495
            <ConfirmationBox
-
 
496
              show={showUnblockConfirmationBox}
-
 
497
              onClose={() => handleUnblockConfirmationBox(false)}
-
 
498
              onAccept={() => handleCancelApply(link_unblock)}
-
 
499
            />
-
 
500
          </div>
-
 
501
        )
-
 
502
      }
-
 
503
      {
-
 
504
        link_leave && (
-
 
505
          <div style={{ position: "relative" }}>
-
 
506
            <ConfirmationBox
-
 
507
              show={showLeaveConfirmationBox}
-
 
508
              onClose={() => handleLeaveConfirmationBox(false)}
-
 
509
              onAccept={() => handleCancelApply(link_leave)}
-
 
510
            />
-
 
511
          </div>
-
 
512
        )
-
 
513
      }
343
      }
514
      {
-
 
515
        link_impersonate
344
      {link_impersonate &&
516
        &&
345
        <li>
517
        <li>
346
          <a
-
 
347
            href="#"
-
 
348
            className="btn btn-primary"
-
 
349
            onClick={(e) => {
-
 
350
              e.preventDefault()
518
          <a
351
              getImpersonateUrl(link_impersonate)
-
 
352
            }}
-
 
353
          >
-
 
354
            Personificar
-
 
355
          </a>
519
            href="#" onClick={() => getImpersonateUrl(link_impersonate)} > Personificar </a>
356
        </li>
520
        </li>
357
      }
521
      }
358
      {
522
      {
359
        loading &&
523
        loading &&