Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3921 Rev 4006
Línea 2... Línea 2...
2
import { useDispatch } from "react-redux";
2
import { useDispatch } from "react-redux";
3
import { addNotification } from "../../../redux/notification/notification.actions";
3
import { addNotification } from "../../../redux/notification/notification.actions";
4
import { axios } from "../../../utils";
4
import { axios } from "../../../utils";
Línea 5... Línea 5...
5
 
5
 
6
const PeopleYouMayKnow = () => {
6
const PeopleYouMayKnow = () => {
7
  // states
7
 
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
Línea -... Línea 9...
-
 
9
  const dispatch = useDispatch()
-
 
10
 
-
 
11
  const getSuggestion = async (url = `/helpers/people-you-may-know`) => {
-
 
12
    try {
-
 
13
      const { data } = await axios.get(url)
-
 
14
      const resData = [...data.data].slice(0, 3);
-
 
15
      if (data.success) setPeopleYouMayKnow(resData);
-
 
16
    } catch (error) {
-
 
17
      console.log(error);
-
 
18
    }
9
  const dispatch = useDispatch()
19
  }
10
 
20
 
11
  const handleConnect = (url) => {
21
  const handleConnect = (url) => {
12
    axios.post(url)
22
    axios.post(url)
13
      .then(({ data }) => {
23
      .then(({ data }) => {
Línea 18... Línea 28...
18
              ? data.data
28
              ? data.data
19
              : 'Ha ocurrido un error'
29
              : 'Ha ocurrido un error'
20
          }))
30
          }))
21
        }
31
        }
Línea 22... Línea 32...
22
 
32
 
23
        dispatch(addNotification({
-
 
24
          style: 'success',
-
 
25
          msg: data.data
-
 
26
        }))
33
        dispatch(addNotification({ style: 'success', msg: data.data }))
27
        return getSuggestion()
34
        return getSuggestion()
28
      })
35
      })
Línea 29... Línea -...
29
  }
-
 
30
 
36
  }
31
  const getSuggestion = (url = `/helpers/people-you-may-know`) => {
37
 
32
    axios.get(url)
-
 
33
      .then(({ data }) => {
-
 
34
        const resData = [...data.data].slice(0, 3);
38
  useEffect(() => {
35
        if (data.success) setPeopleYouMayKnow(resData);
-
 
36
      });
-
 
37
  }
-
 
Línea 38... Línea 39...
38
 
39
    getSuggestion()
39
  useEffect(() => getSuggestion(), []);
40
  }, []);
40
 
41
 
41
  return (
42
  return (