Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2838 Rev 2854
Línea 1... Línea 1...
1
import React, { useMemo, useState } from 'react'
1
import React, { useState } from 'react'
2
import { useNavigate } from 'react-router-dom'
2
import { useNavigate } from 'react-router-dom'
3
import { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
Línea 4... Línea 4...
4
 
4
 
5
import { axios } from '@app/utils'
5
import { axios } from '@app/utils'
Línea 11... Línea 11...
11
import Options from '@components/UI/Option'
11
import Options from '@components/UI/Option'
12
import ConfirmModal from '@components/modals/ConfirmModal'
12
import ConfirmModal from '@components/modals/ConfirmModal'
Línea 13... Línea 13...
13
 
13
 
14
export default function FeedHeader({ id }) {
14
export default function FeedHeader({ id }) {
15
  const [showConfirmModal, setShowConfirmModal] = useState(false)
-
 
16
  const labels = useSelector(({ intl }) => intl.labels)
15
  const [showConfirmModal, setShowConfirmModal] = useState(false)
17
  const navigate = useNavigate()
16
  const navigate = useNavigate()
Línea 18... Línea 17...
18
  const dispatch = useDispatch()
17
  const dispatch = useDispatch()
Línea 54... Línea 53...
54
      })
53
      })
55
    )
54
    )
Línea 56... Línea 55...
56
 
55
 
Línea 57... Línea -...
57
  const toggleConfirm = () => setShowConfirmModal(!showConfirmModal)
-
 
58
 
-
 
59
  const options = useMemo(() => {
-
 
60
    const defaultOptions = []
-
 
61
 
-
 
62
    if (deleteUrl) {
-
 
63
      defaultOptions.push({ action: toggleConfirm, label: labels.delete })
-
 
64
    }
-
 
65
 
-
 
66
    if (reportUrl) {
-
 
67
      defaultOptions.push({
-
 
68
        action: () => reportFeed(reportUrl),
-
 
69
        label: 'Reportar'
-
 
70
      })
-
 
71
    }
-
 
72
 
-
 
73
    return defaultOptions
-
 
74
  }, [deleteUrl, reportUrl])
56
  const toggleConfirm = () => setShowConfirmModal(!showConfirmModal)
75
 
57
 
76
  return (
58
  return (
77
    <>
59
    <>
78
      <Widget.Header
60
      <Widget.Header
79
        avatar={image}
61
        avatar={image}
80
        title={name}
62
        title={name}
81
        onClick={() => navigate(profileUrl)}
63
        onClick={() => navigate(profileUrl)}
-
 
64
        subheader={timeElapse}
-
 
65
        renderAction={() => (
-
 
66
          <Options>
-
 
67
            {reportUrl ? (
-
 
68
              <Options.Item onClick={reportFeed}>Reportar</Options.Item>
-
 
69
            ) : null}
82
        subheader={timeElapse}
70
 
-
 
71
            {deleteUrl ? (
-
 
72
              <Options.Item onClick={toggleConfirm}>Borrar</Options.Item>
83
        renderAction={() =>
73
            ) : null}
84
          options.length ? <Options options={options} right='.5rem' /> : null
74
          </Options>
85
        }
75
        )}
86
      />
76
      />
87
      <ConfirmModal
77
      <ConfirmModal
88
        show={showConfirmModal}
78
        show={showConfirmModal}