Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4012 Rev 4014
Línea 1... Línea -...
1
/* eslint-disable react/prop-types */
-
 
2
import React from "react";
1
import React, { useEffect, useState } from "react";
3
import { useDispatch } from "react-redux";
2
import { useDispatch } from "react-redux";
4
import useFetchHelper from "../../../hooks/useFetchHelper";
-
 
5
import { addNotification } from "../../../redux/notification/notification.actions";
3
import { addNotification } from "../../../redux/notification/notification.actions";
6
import { axios } from "../../../utils";
4
import { axios } from "../../../utils";
Línea 7... Línea 5...
7
 
5
 
Línea 8... Línea 6...
8
const PeopleYouMayKnow = ({ url = `/helpers/people-you-may-know` }) => {
6
const PeopleYouMayKnow = () => {
9
 
7
 
Línea 10... Línea 8...
10
  const { data: peopleYouMayKnow } = useFetchHelper(url)
8
  const [peopleYouMayKnow, setPeopleYouMayKnow] = useState([]);
11
  const dispatch = useDispatch()
9
  const dispatch = useDispatch()
12
 
10
 
Línea 20... Línea 18...
20
              ? data.data
18
              ? data.data
21
              : 'Ha ocurrido un error'
19
              : 'Ha ocurrido un error'
22
          }))
20
          }))
23
        }
21
        }
Línea 24... Línea 22...
24
 
22
 
-
 
23
        dispatch(addNotification({
-
 
24
          style: 'success',
25
        dispatch(addNotification({ style: 'success', msg: data.data }))
25
          msg: data.data
-
 
26
        }))
26
        return
27
        return getSuggestion()
27
      })
28
      })
Línea -... Línea 29...
-
 
29
  }
-
 
30
 
-
 
31
  const getSuggestion = async (url = `/helpers/people-you-may-know`) => {
-
 
32
    try {
-
 
33
      const { data } = await axios.get(url)
-
 
34
      const resData = [...data.data].slice(0, 3);
-
 
35
      if (data.success) setPeopleYouMayKnow(resData);
-
 
36
    } catch (error) {
-
 
37
      console.log(error);
-
 
38
    }
-
 
39
  }
-
 
40
 
-
 
41
  useEffect(() => {
-
 
42
    getSuggestion()
28
  }
43
  }, []);
29
 
44
 
30
  return (
45
  return (
31
    <div className='peopleYouMayKnow'>
46
    <div className='peopleYouMayKnow'>
32
      <div className="sd-title d-flex align-items-center justify-content-between">
47
      <div className="sd-title d-flex align-items-center justify-content-between">
33
        <h3>Conecta con:</h3>
48
        <h3>Conecta con:</h3>
34
        <a href="/connection/people-you-may-know" target="_blank">
49
        <a href="/connection/people-you-may-know" target="_blank">
35
          Ver más
50
          Ver más
36
        </a>
51
        </a>
37
      </div>
52
      </div>
38
      <div className='suggest-list'>
53
      <div className='suggest-list'>
39
        {peopleYouMayKnow
54
        {peopleYouMayKnow.length
40
          ? peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile }) =>
55
          ? peopleYouMayKnow.map(({ id, image, link_cancel, link_request, name, profile }) =>
41
            <div className='user' key={id}>
56
            <div className='user' key={id}>
42
              <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
57
              <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>