Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5435 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5435 Rev 5793
Línea 5... Línea 5...
5
import { useSelector } from 'react-redux'
5
import { useSelector } from 'react-redux'
Línea 6... Línea 6...
6
 
6
 
7
const SuggestWidget = ({
7
const SuggestWidget = ({
8
  title = 'Mis Grupos:',
8
  title = 'Mis Grupos:',
9
  url = '/helpers/my-groups',
9
  url = '/helpers/my-groups',
10
  btnLabelAccept = 'Ver'
10
  btnLabelAccept = 'Ver',
11
}) => {
11
}) => {
12
  const [widgetData, setWidgetData] = useState([])
12
  const [widgetData, setWidgetData] = useState([])
13
  const [lookMore, setLookMore] = useState(false)
13
  const [lookMore, setLookMore] = useState(false)
Línea 14... Línea 14...
14
  const labels = useSelector(state => state.labels)
14
  const labels = useSelector((state) => state.labels)
15
 
-
 
16
  const getData = () => {
15
 
17
    axios.get(url)
16
  const getData = () => {
18
      .then(({ data: response }) => {
17
    axios.get(url).then(({ data: response }) => {
19
        const { success, data } = response
18
      const { success, data } = response
20
        if (success) {
19
      if (success) {
21
          setWidgetData(data.sort((a, b) => a.priority - b.priority).reverse())
20
        setWidgetData(data.sort((a, b) => a.priority - b.priority).reverse())
22
        }
21
      }
Línea 23... Línea 22...
23
      })
22
    })
24
  }
23
  }
25
 
24
 
Línea 36... Línea 35...
36
 
35
 
37
    return infoFollows
36
    return infoFollows
Línea 38... Línea 37...
38
  }
37
  }
39
 
38
 
40
  return (
39
  return (
41
    <div className='suggests_widget'>
40
    <div className="suggests_widget">
42
      <div className="suggests_widget-header">
41
      <div className="suggests_widget-header">
43
        <h3>{title}</h3>
42
        <h3>{title}</h3>
44
        {widgetData.length >= 3 &&
43
        {widgetData.length >= 3 && (
45
          <span onClick={() => setLookMore(!lookMore)}>
44
          <span onClick={() => setLookMore(!lookMore)}>
-
 
45
            {lookMore ? labels.VIEW_LESS : labels.VIEW_MORE}
46
            {lookMore ? labels.VIEW_LESS : labels.VIEW_MORE}
46
          </span>
47
          </span>}
47
        )}
48
      </div>
48
      </div>
-
 
49
      <div className="suggest-list">
-
 
50
        {widgetData.length ? (
-
 
51
          dataSlice().map((suggest) => (
-
 
52
            <SuggestWidget.Item
49
      <div className="suggest-list">
53
              key={suggest.id}
-
 
54
              suggest={suggest}
-
 
55
              btnLabelAccept={btnLabelAccept}
-
 
56
            />
50
        {widgetData.length
57
          ))
51
          ? dataSlice().map((suggest) => <SuggestWidget.Item key={suggest.id} suggest={suggest} btnLabelAccept={btnLabelAccept}/>)
58
        ) : (
52
          : <EmptySection align='left' message={labels.DATATABLE_EMPTY} />
59
          <EmptySection align="left" message={labels.DATATABLE_EMPTY} />
53
        }
60
        )}
54
      </div>
61
      </div>
55
    </div>
62
    </div>
Línea 56... Línea 63...
56
  )
63
  )
57
}
64
}
58
 
65
 
59
const Item = ({ suggest, btnLabelAccept }) => {
66
const Item = ({ suggest, btnLabelAccept }) => {
60
  return (
67
  return (
61
    <div className='user'>
68
    <div className="user">
62
      <div className="d-inline-flex align-items-center">
69
      <div className="d-inline-flex align-items-center">
63
        <a href={suggest.profile} target="_blank" rel="noreferrer">
70
        <a href={suggest.profile} target="_blank" rel="noreferrer">
64
          <img src={suggest.image} alt={`${suggest.name} profile image`} />
71
          <img src={suggest.image} alt={`${suggest.name} profile image`} />
65
        </a>
72
        </a>
66
        <h4 className='break-ellipsis'>{suggest.name}</h4>
73
        <h4 className="break-ellipsis">{suggest.name}</h4>
67
      </div>
74
      </div>
68
      <a className="btn btn-primary ml-auto" href={suggest.profile}>
75
      <a className="btn btn-primary ml-auto" href={suggest.profile}>