Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 2887 Rev 2888
Línea 9... Línea 9...
9
  // states
9
  // states
10
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
10
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
11
  const [error, setError] = useState("");
11
  const [error, setError] = useState("");
12
  const dispatch = useDispatch()
12
  const dispatch = useDispatch()
Línea 13... Línea -...
13
 
-
 
14
  useEffect(() => {
-
 
15
    axios.get(`/helpers/people-you-may-know`).then((response) => {
-
 
16
      const resData = response.data;
-
 
17
      if (resData.success) {
-
 
18
        setPeopleYouMayKnow(resData.data);
-
 
19
      } else {
-
 
20
        // alert error
-
 
21
      }
-
 
22
    });
-
 
23
  }, []);
-
 
24
 
13
 
25
  const handleConnect = (url) => {
14
  const handleConnect = (url) => {
26
    axios.post(url)
15
    axios.post(url)
27
      .then(({ data }) => {
16
      .then(({ data }) => {
28
        if (!data.success) {
17
        if (!data.success) {
Línea 32... Línea 21...
32
              ? data.data
21
              ? data.data
33
              : 'Ha ocurrido un error'
22
              : 'Ha ocurrido un error'
34
          }))
23
          }))
35
        }
24
        }
Línea 36... Línea 25...
36
 
25
 
37
        return dispatch(addNotification({
26
        dispatch(addNotification({
38
          style: 'success',
27
          style: 'success',
39
          msg: data.data
28
          msg: data.data
-
 
29
        }))
40
        }))
30
        return getSuggestion()
41
      })
31
      })
Línea -... Línea 32...
-
 
32
  }
-
 
33
 
-
 
34
  const getSuggestion = (url) => {
-
 
35
    axios.get(`/helpers/people-you-may-know`).then((response) => {
-
 
36
      const resData = response.data;
-
 
37
      if (resData.success) {
-
 
38
        setPeopleYouMayKnow(resData.data);
-
 
39
      } else {
-
 
40
        // alert error
-
 
41
      }
-
 
42
    });
-
 
43
  }
-
 
44
 
-
 
45
  useEffect(() => {
-
 
46
    getSuggestion()
42
  }
47
  }, []);
43
 
48
 
44
  return (
49
  return (
45
    <div className={styles.peopleYouMayKnow} id="suggestions-list-people-you-may-know">
50
    <div className={styles.peopleYouMayKnow} id="suggestions-list-people-you-may-know">
46
      <div className="sd-title">
51
      <div className="sd-title">
Línea 53... Línea 58...
53
              {error ? (
58
              {error ? (
54
                <div className="suggestion-usd"> Ha ocurrido un error :( </div>
59
                <div className="suggestion-usd"> Ha ocurrido un error :( </div>
55
              ) : (
60
              ) : (
56
                peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile, relation }) => (
61
                peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile, relation }) => (
57
                  <div className={styles.user} key={id}>
62
                  <div className={styles.user} key={id}>
58
                    <div className="w-100 d-flex align-items-center">
63
                    <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
59
                      <a href={profile} target="_blank">
64
                      <a href={profile} target="_blank">
60
                        <img src={image} alt={`${name} profile image`} />
65
                        <img src={image} alt={`${name} profile image`} />
61
                      </a>
66
                      </a>
62
                      <h4>{name}</h4>
67
                      <h4>{name}</h4>
63
                    </div>
68
                    </div>
64
                    <div className="w-100 d-flex align-items-center justify-content-center">
69
                    <div className="w-100 d-flex align-items-center justify-content-center" style={{ gap: '.5rem' }}>
65
                      {
70
                      {
66
                        link_request
71
                        link_request
67
                        &&
72
                        &&
68
                        <button
73
                        <button
69
                          className="btn btn-primary"
74
                          className="btn btn-primary"