Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3290 Rev 3506
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React from "react";
2
import React from "react";
3
import { useEffect, useState } from "react";
3
import { useEffect, useState } from "react";
4
import { axios } from "../../../utils";
4
import { axios } from "../../../utils";
5
import styles from "../people-you-may-know/peopleYouMayKnow.module.scss";
-
 
Línea 6... Línea 5...
6
 
5
 
7
const SuggestedGroupsHelper = (props) => {
-
 
8
  // props destructuring
-
 
Línea 9... Línea 6...
9
  const { groupId } = props;
6
const SuggestedGroupsHelper = ({ groupId }) => {
10
 
7
 
11
  // states
8
  // states
-
 
9
  const [suggestedGroups, setSuggestedGroups] = useState([]);
12
  const [suggestedGroups, setSuggestedGroups] = useState([]);
10
  const [lookMore, setLookMore] = useState(false);
13
  const [lookMore, setLookMore] = useState(false);
11
 
Línea 14... Línea 12...
14
  useEffect(() => {
12
  useEffect(() => {
15
    const url = '/helpers/groups-suggestion'
13
    const url = '/helpers/groups-suggestion'
16
 
14
 
17
    axios.get(url)
15
    axios.get(url)
18
      .then(({ data }) => {
-
 
19
        if (data.success) {
16
      .then(({ data }) =>
20
          setSuggestedGroups(data.data.sort((a, b) => parseInt(a.priority) - parseInt(b.priority)).reverse());
17
        data.success &&
Línea 21... Línea 18...
21
        }
18
        setSuggestedGroups(data.data.sort((a, b) => parseInt(a.priority) - parseInt(b.priority)).reverse())
22
      });
19
      )
23
  }, []);
20
  }, []);
24
 
21
 
25
  const getData = () => {
22
  const getData = () => {
26
    let infoFollows = [...suggestedGroups]
23
    let infoFollows = [...suggestedGroups]
27
    if (!lookMore) {
24
    if (!lookMore) {
28
      infoFollows = infoFollows.slice(0, 3);
25
      infoFollows = infoFollows.slice(0, 3);
29
    }
26
    }
30
    return infoFollows
27
    return infoFollows
31
  }
28
  }
32
  return (
-
 
33
    <div className={styles.peopleYouMayKnow}>
29
  return (
34
      <div className="sd-title d-flex align-items-center justify-content-between">
30
    <div className='peopleYouMayKnow'>
35
        <h3>Grupos:</h3>
31
      <div className="sd-title d-flex align-items-center justify-content-between">
36
        {
32
        <h3>Grupos:</h3>
37
          suggestedGroups.length >= 3 &&
33
        {suggestedGroups.length >= 3 &&
38
          <a
34
          <a
Línea 49... Línea 45...
49
      <div
45
      <div
50
        className="mb-2"
46
        className="mb-2"
51
        id="suggestions-similar-groups"
47
        id="suggestions-similar-groups"
52
        style={{ height: "80%", overflowY: "auto" }}
48
        style={{ height: "80%", overflowY: "auto" }}
53
      >
49
      >
54
        {suggestedGroups.length ? (
50
        {suggestedGroups.length
55
          getData().map(({ id, name, image, profile }) => (
51
          ? getData().map(({ id, name, image, profile }) =>
56
            <div className={styles.user} key={id}>
52
            <div className='user' key={id}>
57
              <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
53
              <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
58
                <a href={profile} target="_blank" rel="noreferrer">
54
                <a href={profile} target="_blank" rel="noreferrer">
59
                  <img src={image} alt={`${name} profile image`} />
55
                  <img src={image} alt={`${name} profile image`} />
60
                </a>
56
                </a>
61
                <h4>{name}</h4>
57
                <h4>{name}</h4>
Línea 67... Línea 63...
67
                >
63
                >
68
                  Ver Grupo
64
                  Ver Grupo
69
                </a>
65
                </a>
70
              </div>
66
              </div>
71
            </div>
67
            </div>
72
          ))
68
          )
73
        ) : (
-
 
74
          <div className="view-more">Sin sugerencias</div>
69
          : <div className="view-more">Sin sugerencias</div>
75
        )}
70
        }
76
      </div>
71
      </div>
77
    </div>
72
    </div>
78
  );
73
  );
79
};
74
};