Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1599 Rev 1600
Línea 13... Línea 13...
13
const JoinedGroups = (props) => {
13
const JoinedGroups = (props) => {
14
  // states
14
  // states
15
  const [joinedGroups, setJoinedGroups] = useState([]);
15
  const [joinedGroups, setJoinedGroups] = useState([]);
16
  const [loading, setLoading] = useState(true);
16
  const [loading, setLoading] = useState(true);
Línea 17... Línea -...
17
 
-
 
18
  // redux destructuring
-
 
19
  const { addNotification } = props;
-
 
20
 
-
 
21
  // React hook form
-
 
22
  const { register, getValues } = useForm();
-
 
23
 
-
 
24
  let axiosThrottle = null;
-
 
25
 
17
 
26
  useEffect(() => {
18
  useEffect(() => {
27
    fetchJoinedGroups();
-
 
28
    return () => {
-
 
29
      clearTimeout(axiosThrottle);
-
 
30
    };
19
    fetchJoinedGroups();
Línea 31... Línea 20...
31
  }, []);
20
  }, []);
32
 
21
 
33
  const fetchJoinedGroups = async (searchParam = '') => {
22
  const fetchJoinedGroups = async (searchParam = '') => {
Línea 44... Línea 33...
44
        }
33
        }
45
      });
34
      });
46
    setLoading(false);
35
    setLoading(false);
47
  };
36
  };
Línea 48... Línea -...
48
 
-
 
49
  const handleLeaveGroup = (link) => {
-
 
50
    setLoading(true);
-
 
51
    axios.post(link).then((response) => {
-
 
52
      const resData = response.data;
-
 
53
      if (resData.success) {
-
 
54
        addNotification({
-
 
55
          style: "success",
-
 
56
          msg: resData.data,
-
 
57
        });
-
 
58
        fetchCompanies();
-
 
59
      } else {
-
 
60
        setLoading(false);
-
 
61
        addNotification({
-
 
62
          style: "danger",
-
 
63
          msg: resData.data ?? "ha ocurrido un error",
-
 
64
        });
-
 
65
      }
-
 
66
    });
-
 
67
  };
-
 
68
 
-
 
69
  const handleSearch = () => {
-
 
70
    //  (getValues());
-
 
71
    clearTimeout(axiosThrottle);
-
 
72
    // setLoading(true);
-
 
73
    const searchValue = getValues("search");
-
 
74
    axiosThrottle = setTimeout(() => {
-
 
75
      fetchJoinedGroups(searchValue);
-
 
76
    }, 500);
-
 
77
  };
-
 
78
 
37
 
79
  return (
38
  return (
80
    <section className="companies-info" style={{ position: "relative" }}>
39
    <section className="companies-info" style={{ position: "relative" }}>
81
      <div className="container">
40
      <div className="container">
82
        <SearchList
41
        <SearchList
Línea 95... Línea 54...
95
                      name={name}
54
                      name={name}
96
                      status={privacy}
55
                      status={privacy}
97
                      link_view={link_view}
56
                      link_view={link_view}
98
                      link_leave={link_leave}
57
                      link_leave={link_leave}
99
                      key={index}
58
                      key={index}
-
 
59
                      fetchCallback={fetchJoinedGroups}
100
                    />
60
                    />
101
                  ))
61
                  ))
102
                :
62
                :
103
                <div style={{ margin: "auto", textAlign: "center" }}>
63
                <div style={{ margin: "auto", textAlign: "center" }}>
104
                  Ningún registro coincidio con su consulta
64
                  Ningún registro coincidio con su consulta