Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4007 Rev 4009
Línea 6... Línea 6...
6
const PeopleYouMayKnow = () => {
6
const PeopleYouMayKnow = () => {
Línea 7... Línea 7...
7
 
7
 
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
Línea 9... Línea -...
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
    }
-
 
19
  }
9
  const dispatch = useDispatch()
20
 
10
 
21
  const handleConnect = (url) => {
11
  const handleConnect = (url) => {
22
    axios.post(url)
12
    axios.post(url)
23
      .then(({ data }) => {
13
      .then(({ data }) => {
Línea 29... Línea 19...
29
              : 'Ha ocurrido un error'
19
              : 'Ha ocurrido un error'
30
          }))
20
          }))
31
        }
21
        }
Línea 32... Línea 22...
32
 
22
 
33
        dispatch(addNotification({ style: 'success', msg: data.data }))
23
        dispatch(addNotification({ style: 'success', msg: data.data }))
34
        return getSuggestion()
24
        return
35
      })
25
      })
Línea 36... Línea -...
36
  }
-
 
37
 
-
 
38
  console.log('People rendered successfully')
26
  }
-
 
27
 
-
 
28
  useEffect(() => {
-
 
29
    const getSuggestion = async (url = `/helpers/people-you-may-know`) => {
-
 
30
      try {
-
 
31
        const { data } = await axios.get(url)
-
 
32
        const resData = [...data.data].slice(0, 3);
-
 
33
        if (data.success) return setPeopleYouMayKnow(resData);
-
 
34
      } catch (error) {
-
 
35
        console.log(error);
-
 
36
      }
39
 
37
    }
40
  useEffect(() => {
38
 
Línea 41... Línea 39...
41
    getSuggestion()
39
    getSuggestion()
42
  }, []);
40
  }, []);