Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1156 Rev 1596
Línea 4... Línea 4...
4
import { axios } from "../../../utils";
4
import { axios } from "../../../utils";
5
import Spinner from "../../../shared/loading-spinner/Spinner";
5
import Spinner from "../../../shared/loading-spinner/Spinner";
6
import { connect } from "react-redux";
6
import { connect } from "react-redux";
7
import { addNotification } from "../../../redux/notification/notification.actions";
7
import { addNotification } from "../../../redux/notification/notification.actions";
8
import CompanyTemplate from "./companyTemplate/CompanyTemplate";
8
import CompanyTemplate from "./companyTemplate/CompanyTemplate";
-
 
9
import SearchList from "../../../components/SearchList";
-
 
10
import Profile from "../../../components/Profile";
Línea 9... Línea 11...
9
 
11
 
10
const RequestSent = (props) => {
-
 
11
  // redux destructuring
-
 
12
  const { addNotification } = props;
-
 
13
 
12
const RequestSent = (props) => {
14
  // states
13
  // states
15
  const [companies, setCompanies] = useState([]);
14
  const [companies, setCompanies] = useState([]);
16
  const [loading, setLoading] = useState(true);
-
 
17
 
-
 
18
  // React hook form
-
 
19
  const { register, getValues } = useForm();
-
 
20
 
-
 
21
  let axiosThrottle = null;
-
 
22
 
15
  const [loading, setLoading] = useState(true);
23
  useEffect(() => {
16
  useEffect(() => {
24
    fetchCompanies();
-
 
25
    return () => {
-
 
26
      clearTimeout(axiosThrottle);
-
 
27
    };
17
    fetchCompanies();
Línea 28... Línea 18...
28
  }, []);
18
  }, []);
29
 
19
 
30
  const fetchCompanies = async (searchParam = '') => {
20
  const fetchCompanies = async (searchParam = '') => {
Línea 39... Línea 29...
39
        }
29
        }
40
      });
30
      });
41
    setLoading(false);
31
    setLoading(false);
42
  };
32
  };
Línea 43... Línea -...
43
 
-
 
44
  const handleSearch = () => {
-
 
45
    //  (getValues());
-
 
46
    clearTimeout(axiosThrottle);
-
 
47
    // setLoading(true);
-
 
48
    const searchValue = getValues("search");
-
 
49
    axiosThrottle = setTimeout(() => {
-
 
50
      fetchCompanies(searchValue);
-
 
51
    }, 500);
-
 
52
  };
-
 
53
 
-
 
54
  const handleCancelRequest = (link) => {
-
 
55
    setLoading(true);
-
 
56
    axios.post(link).then((response) => {
-
 
57
      const resData = response.data;
-
 
58
      if (resData.success) {
-
 
59
        addNotification({
-
 
60
          style: "success",
-
 
61
          msg: resData.data,
-
 
62
        });
-
 
63
        fetchCompanies();
-
 
64
      } else {
-
 
65
        setLoading(false);
-
 
66
        addNotification({
-
 
67
          style: "danger",
-
 
68
          msg: resData.data ?? "ha ocurrido un error",
-
 
69
        });
-
 
70
      }
-
 
71
    });
-
 
72
  };
-
 
73
 
33
 
74
  return (
34
  return (
75
    <section className="companies-info">
35
    <section className="companies-info">
76
      <div className="container">
-
 
77
        <div className="company-title">
-
 
78
          <div className="section_admin_title_buttons">
36
      <div className="container">
79
            <div>
37
        <SearchList
80
              <h1 className="title">Solicitudes Enviadas</h1>
-
 
81
            </div>
-
 
82
          </div>
-
 
83
        </div>
38
          title="Solicitudes enviadas"
84
        <div className="company-title">
-
 
85
          <div className="section_admin_title_buttons">
-
 
86
            <form
-
 
87
              name="form-connection-search"
-
 
88
              id="form-connection-search"
-
 
89
              onSubmit={(event) => event.preventDefault()}
39
          fetchCallback={fetchCompanies}
90
            >
-
 
91
              <div className="form-group">
-
 
92
                <input
-
 
93
                  type="text"
-
 
94
                  name="search"
-
 
95
                  id="search"
-
 
96
                  className="form-control"
-
 
97
                  placeholder="Buscar"
-
 
98
                  ref={register}
-
 
99
                  onChange={handleSearch}
-
 
100
                />
-
 
101
              </div>
-
 
102
            </form>
-
 
103
          </div>
40
        />
104
        </div>
41
 
105
        <div className="companies-list">
42
        <div className="companies-list">
106
          <div
43
          <div
107
            className="row"
44
            className="row"
108
            id="profiles-container"
45
            id="profiles-container"
109
            style={{
46
            style={{
110
              position: "relative",
47
              position: "relative",
111
            }}
48
            }}
112
          >
49
          >
113
            {companies.length > 0 ? (
50
            {companies.length > 0 ? (
114
              companies.map((company, id) => (
51
              companies.map(({name, image, link_cancel, link_view}, id) => (
115
                <CompanyTemplate
52
                <Profile
-
 
53
                  name={name}
-
 
54
                  link_cancel={link_cancel}
116
                  company={company}
55
                  link_view={link_view}
117
                  key={id}
56
                  key={id}
118
                  onCancel={handleCancelRequest}
57
                  fetchCallback={fetchCompanies}
119
                />
58
                />
120
              ))
59
              ))
121
            ) : (
60
            ) : (
122
              <div style={{ margin: "auto", textAlign: "center" }}>
61
              <div style={{ margin: "auto", textAlign: "center" }}>