Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

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