Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 2883 Rev 2885
Línea 1... Línea 1...
1
import React, { useEffect, useState } from "react";
1
import React, { useEffect, useState } from "react";
-
 
2
import { useDispatch } from "react-redux";
-
 
3
import { addNotification } from "../../../redux/notification/notification.actions";
2
import { axios } from "../../../utils";
4
import { axios } from "../../../utils";
Línea 3... Línea 5...
3
 
5
 
Línea 4... Línea 6...
4
import styles from "./peopleYouMayKnow.module.scss";
6
import styles from "./peopleYouMayKnow.module.scss";
5
 
7
 
6
const PeopleYouMayKnow = () => {
8
const PeopleYouMayKnow = () => {
7
  // states
9
  // states
-
 
10
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
Línea 8... Línea 11...
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
11
  const [error, setError] = useState("");
9
  const [error, setError] = useState("");
12
  const dispatch = useDispatch()
10
 
13
 
11
  useEffect(() => {
14
  useEffect(() => {
Línea 17... Línea 20...
17
        // alert error
20
        // alert error
18
      }
21
      }
19
    });
22
    });
20
  }, []);
23
  }, []);
Línea -... Línea 24...
-
 
24
 
-
 
25
  const handleConnect = (url) => {
-
 
26
    axios.post(url)
-
 
27
      .then(({ data }) => {
-
 
28
        if (!data.success) {
-
 
29
          return dispatch(addNotification({
-
 
30
            style: 'danger',
-
 
31
            msg: typeof data.data === 'string'
-
 
32
              ? data.data
-
 
33
              : 'Ha ocurrido un error'
-
 
34
          }))
-
 
35
        }
-
 
36
 
-
 
37
        return dispatch(addNotification({
-
 
38
          style: 'success',
-
 
39
          msg: data.data
-
 
40
        }))
-
 
41
      })
-
 
42
  }
21
 
43
 
22
  return (
44
  return (
23
    <div className={styles.peopleYouMayKnow} id="suggestions-list-people-you-may-know">
45
    <div className={styles.peopleYouMayKnow} id="suggestions-list-people-you-may-know">
24
      <div className="sd-title">
46
      <div className="sd-title">
25
        <h3>Personas que puede conocer</h3>
47
        <h3>Personas que puede conocer</h3>
Línea 31... Línea 53...
31
              {error ? (
53
              {error ? (
32
                <div className="suggestion-usd"> Ha ocurrido un error :( </div>
54
                <div className="suggestion-usd"> Ha ocurrido un error :( </div>
33
              ) : (
55
              ) : (
34
                peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile, relation }) => (
56
                peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile, relation }) => (
35
                  <div className={styles.user} key={id}>
57
                  <div className={styles.user} key={id}>
36
                    <a href={profile} target="_blank">
-
 
37
                      <img
-
 
38
                        style={{
-
 
39
                          width: "2.3rem",
-
 
40
                          maxWidth: '2.3rem',
-
 
41
                          height: "auto"
-
 
42
                        }}
-
 
43
                        src={image}
-
 
44
                        alt={`${name} profile image`}
-
 
45
                      />
-
 
46
                    </a>
-
 
47
 
-
 
48
                    <div className="sgt-text">
58
                    <div className="d-flex align-items-center">
49
                      <a href={profile} target="_blank">
59
                      <a href={profile} target="_blank">
50
                        <h4>{name}</h4>
60
                        <img src={image} alt={`${name} profile image`} />
51
                      </a>
61
                      </a>
-
 
62
                      <h4>{name}</h4>
-
 
63
                    </div>
-
 
64
                    <div className="d-flex align-items-center">
-
 
65
                      {
-
 
66
                        link_request
-
 
67
                        &&
-
 
68
                        <button
-
 
69
                          className="btn btn-primary"
-
 
70
                          onClick={() => handleConnect(link_request)}
-
 
71
                        >
-
 
72
                          Conectar
-
 
73
                        </button>
-
 
74
                      }
-
 
75
                      {
-
 
76
                        link_cancel
-
 
77
                        &&
-
 
78
                        <button
-
 
79
                          className="btn btn-secondary"
-
 
80
                          onClick={() => handleConnect(link_cancel)}
-
 
81
                        >
-
 
82
                          Cancelar
-
 
83
                        </button>
-
 
84
                      }
52
                    </div>
85
                    </div>
53
                  </div>
86
                  </div>
54
                ))
87
                ))
55
              )}
88
              )}
Línea 73... Línea 106...
73
              </a>
106
              </a>
74
            </div>
107
            </div>
75
          )
108
          )
76
        }
109
        }
77
      </>
110
      </>
78
    </div>
111
    </div >
79
  );
112
  );
80
};
113
};
Línea 81... Línea 114...
81
 
114