Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4240 | Rev 5087 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4241 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useEffect, useState } from "react";
1158 stevensc 3
import { axios } from "../../../utils";
1 www 4
import Spinner from "../../../shared/loading-spinner/Spinner";
2335 stevensc 5
import Profile from "../../../components/Profile";
2336 stevensc 6
import SearchList from "../../../components/SearchList";
1 www 7
 
4241 stevensc 8
const InvitationsReceived = () => {
1 www 9
 
10
  const [companies, setCompanies] = useState([]);
11
  const [loading, setLoading] = useState(true);
12
 
13
  let axiosThrottle = null;
14
 
15
  useEffect(() => {
16
    fetchCompanies();
17
    return () => {
18
      clearTimeout(axiosThrottle);
19
    };
20
  }, []);
21
 
4241 stevensc 22
  const fetchCompanies = (searchParam = '') => {
1 www 23
    setLoading(true);
4241 stevensc 24
    axios
1158 stevensc 25
      .get("/company/invitations-received?search=" + searchParam)
4241 stevensc 26
      .then(({ data: response }) => {
27
        if (response.success) {
28
          setCompanies(response.data)
1 www 29
        }
4241 stevensc 30
      })
31
      .finally(() => setLoading(false))
1 www 32
    setLoading(false);
33
  };
34
 
35
  return (
36
    <section className="companies-info">
37
      <div className="container">
2335 stevensc 38
        <SearchList
4239 stevensc 39
          title={LABELS.invitation_received}
2335 stevensc 40
          fetchCallback={fetchCompanies}
41
        />
4241 stevensc 42
        <div className="companies-list position-relative">
43
          {loading && <Spinner />}
2334 stevensc 44
          {
45
            companies.length
46
              ?
2335 stevensc 47
              companies.map(({ image, name, link_view, link_reject, link_accept }, id) => (
48
                <Profile
2334 stevensc 49
                  key={id}
2335 stevensc 50
                  image={image}
51
                  name={name}
52
                  link_view={link_view}
53
                  link_reject={link_reject}
54
                  link_accept={link_accept}
55
                  fetchCallback={fetchCompanies}
2509 stevensc 56
                  btnAcceptTitle='Ver Empresa'
2334 stevensc 57
                />
58
              ))
59
              :
60
              <div style={{ margin: "auto", textAlign: "center" }}>
4240 stevensc 61
                {LABELS.not_found}
1 www 62
              </div>
2334 stevensc 63
          }
1 www 64
        </div>
65
      </div>
2334 stevensc 66
    </section >
1 www 67
  );
68
};
69
 
4241 stevensc 70
export default InvitationsReceived;