Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2505 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2505 Rev 5172
Línea 1... Línea 1...
1
import React from "react";
1
/* eslint-disable react/prop-types */
2
import { useEffect, useState } from "react";
2
/* eslint-disable camelcase */
3
import { useForm } from "react-hook-form";
3
import React, { useEffect, useState } from 'react'
4
import { axios } from "../../../utils";
4
import { debounce } from '../../../utils'
5
import Spinner from "../../../shared/loading-spinner/Spinner";
5
import { connect } from 'react-redux'
6
import { connect } from "react-redux";
6
import { searchEntities } from '../../../services/search'
7
import { addNotification } from "../../../redux/notification/notification.actions";
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import CompanyTemplate from "./companyTemplate/CompanyTemplate";
8
import Spinner from '../../../shared/loading-spinner/Spinner'
9
import SearchList from "../../../components/SearchList";
9
import SearchList from '../../../components/SearchList'
10
import Profile from "../../../components/Profile";
10
import Profile from '../../../components/Profile'
-
 
11
import TitleSection from '../../../components/TitleSection'
-
 
12
import EmptySection from '../../../shared/empty-section/EmptySection'
11
 
13
 
12
const RequestSent = (props) => {
14
const RequestSent = ({ addNotification }) => {
13
  // states
-
 
14
  const [companies, setCompanies] = useState([]);
15
  const [companies, setCompanies] = useState([])
15
  const [loading, setLoading] = useState(true);
16
  const [loading, setLoading] = useState(true)
-
 
17
 
16
  useEffect(() => {
18
  useEffect(() => {
17
    fetchCompanies();
19
    getCompanies()
18
  }, []);
20
  }, [])
-
 
21
 
-
 
22
  const getCompanies = async (searchValue = '') => {
-
 
23
    setLoading(true)
-
 
24
    const response = await searchEntities('company/requests-sent', searchValue)
-
 
25
 
-
 
26
    if (!response.success) {
-
 
27
      addNotification({ style: 'danger', msg: response.data })
-
 
28
      setLoading(false)
-
 
29
      return
-
 
30
    }
-
 
31
 
-
 
32
    setCompanies(response.data)
-
 
33
    setLoading(false)
-
 
34
  }
Línea 19... Línea 35...
19
 
35
 
20
  const fetchCompanies = async (searchParam = '') => {
-
 
21
    setLoading(true);
-
 
22
    await axios
-
 
23
      .get("/company/requests-sent?search=" + searchParam)
-
 
24
      .then((response) => {
-
 
25
        const resData = response.data;
-
 
26
        (resData);
-
 
27
        if (resData.success) {
-
 
28
          setCompanies(resData.data);
-
 
29
        }
-
 
30
      });
-
 
31
    setLoading(false);
-
 
Línea 32... Línea 36...
32
  };
36
  const handleSearch = debounce((value) => getCompanies(value), 500)
33
 
37
 
34
  return (
-
 
35
    <section className="companies-info">
-
 
36
      <div className="container">
38
  return (
37
        <SearchList
39
    <section className="companies-info container">
38
          title="Solicitudes enviadas"
-
 
39
          fetchCallback={fetchCompanies}
-
 
40
        />
-
 
41
 
40
      <TitleSection title={LABELS.REQUESTS_SENT} />
42
        <div
41
      <SearchList onChange={handleSearch} />
43
          className="companies-list"
-
 
44
          id="profiles-container"
42
      <div className="companies-list">
45
          style={{
-
 
46
            position: "relative",
-
 
47
          }}
43
        {loading && <Spinner />}
48
        >
44
        {(!loading && Boolean(!companies.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
49
          {companies.length > 0 ? (
45
        {(!loading && Boolean(companies.length)) &&
50
            companies.map(({ name, image, link_cancel, link_view }, id) => (
46
          companies.map(({ name, image, link_cancel, link_view }, id) =>
51
              <Profile
47
            <Profile
52
                image={image}
48
              image={image}
53
                name={name}
49
              name={name}
54
                link_cancel={link_cancel}
50
              link_cancel={link_cancel}
55
                link_view={link_view}
51
              link_view={link_view}
56
                key={id}
52
              key={id}
57
                fetchCallback={fetchCompanies}
53
              fetchCallback={getCompanies}
58
                btnAcceptTitle='Ver Empresa'
54
              btnAcceptTitle={LABELS.VIEW_COMPANY}
59
                btnCancelTitle='Cancelar solicitud'
-
 
60
              />
-
 
61
            ))
-
 
62
          ) : (
-
 
63
            <div style={{ margin: "auto", textAlign: "center" }}>
-
 
64
              Ningún registro coincidio con su consulta
55
              btnCancelTitle={LABELS.REQUEST_CANCEL}
65
            </div>
-
 
66
          )}
-
 
67
          {loading && (
-
 
68
            <div className="spinner-container">
-
 
69
              <Spinner />
-
 
70
            </div>
-
 
71
          )}
-
 
72
          {/* <!--product-feed-tab end--> */}
56
            />
73
        </div>
57
          )}
74
      </div>
58
      </div>
75
    </section >
59
    </section>
76
  );
-
 
77
};
-
 
Línea 78... Línea 60...
78
 
60
  )
79
// const mapStateToProps = (state) => ({});
61
}
80
 
62
 
Línea 81... Línea 63...
81
const mapDispatchToProps = {
63
const mapDispatchToProps = {