Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4316 Rev 4317
Línea 7... Línea 7...
7
 
7
 
Línea 8... Línea 8...
8
const HelpersContainer = () => {
8
const HelpersContainer = () => {
9
 
9
 
10
  return (
10
  return (
-
 
11
    <div className='sidebar__bottom'>
11
    <div className='sidebar__bottom'>
12
      <HelpersContainer.Item url="/helpers/my-groups" title="Mis Grupos" />
12
      <HelpersContainer.Item />
13
      <HelpersContainer.Item url="/helpers/groups-suggestion" title="Grupos" />
13
    </div>
14
    </div>
Línea 14... Línea 15...
14
  )
15
  )
Línea 15... Línea 16...
15
}
16
}
-
 
17
 
16
 
18
const Item = ({ url = '/helpers/my-groups', title = 'Mis grupos' }) => {
Línea 17... Línea 19...
17
const Item = ({ url = '/helpers/my-groups', title = 'Mis grupos' }) => {
19
 
18
 
20
  const [widgetData, setWidgetData] = useState([]);
19
  const [widgetData, setWidgetData] = useState([]);
21
  const [displayMenu, setDisplayMenu] = useState(false);
20
  const [lookMore, setLookMore] = useState(false);
22
  const [lookMore, setLookMore] = useState(false);
21
 
23
 
22
  const getData = () => {
24
  const getData = () => {
23
    axios.get(url)
25
    axios.get(url)
24
      .then(({ data: response }) => {
26
      .then(({ data: response }) => {
25
        const { success, data } = response
27
        const { success, data } = response
Línea 26... Línea 28...
26
        if (success) {
28
        if (success) {
27
          setWidgetData(data.slice(0, 3).sort((a, b) => a.priority - b.priority).reverse());
29
          setWidgetData(data.sort((a, b) => a.priority - b.priority).reverse());
28
        }
30
        }
Línea -... Línea 31...
-
 
31
      });
-
 
32
  }
-
 
33
 
-
 
34
  useEffect(() => {
-
 
35
    getData()
-
 
36
  }, []);
-
 
37
 
-
 
38
  const dataSlice = () => {
29
      });
39
    let infoFollows = [...widgetData]
30
  }
40
    if (!lookMore) {
Línea 31... Línea 41...
31
 
41
      infoFollows = infoFollows.slice(0, 1)
32
  useEffect(() => {
42
    }
33
    getData()
43
    return infoFollows
34
  }, []);
44
  }
35
 
45
 
36
  return (
46
  return (
37
    <div className='sidebar__recent-item__container'>
47
    <div className='sidebar__recent-item__container'>
38
 
48
 
Línea 39... Línea 49...
39
      <section className='sidebar__recent-item'>
49
      <section className='sidebar__recent-item'>
40
        <p>{title}</p>
50
        <p>{title}</p>
41
        <div className='sidebar__recent-actions'>
51
        <div className='sidebar__recent-actions'>
42
          <button className='sidebar__recent-icon' onClick={() => setLookMore(!lookMore)}>
52
          <button className='sidebar__recent-icon' onClick={() => setDisplayMenu(!displayMenu)}>
43
            <ExpandMoreIcon />
53
            <ExpandMoreIcon />
44
          </button>
54
          </button>
45
        </div>
55
        </div>
46
      </section>
56
      </section>
47
 
57
 
48
      <ul className={`helper__list ${lookMore ? 'show' : 'hide'}`}>
58
      <ul className={`helper__list ${displayMenu ? 'show' : 'hide'}`}>
49
        {widgetData.length
59
        {widgetData.length
50
          ? widgetData.map(({ id, name, profile }) =>
60
          ? dataSlice().map(({ id, name, profile }) =>
-
 
61
            <li key={id}>
-
 
62
              <a href={profile} className='helper__list-item'>
-
 
63
                <GroupIcon />
-
 
64
                <span>{name}</span>
-
 
65
              </a>
-
 
66
            </li>
51
            <li key={id}>
67
          )
52
              <a href={profile} className='helper__list-item'>
68
          : <EmptySection message='Sin resultados' />
Línea 53... Línea 69...
53
                <GroupIcon />
69
        }
54
                <span>{name}</span>
70
        {widgetData.length >= 3 &&
55
              </a>
71
          <li onClick={() => setLookMore(!lookMore)}>