Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 2405 Rev 5151
Línea 1... Línea 1...
1
import React from "react";
1
/* eslint-disable react/prop-types */
-
 
2
/* eslint-disable camelcase */
2
import { useEffect, useState } from "react";
3
import React, { useEffect, useState } from 'react'
3
import { connect } from "react-redux";
4
import { connect } from 'react-redux'
4
import { useForm } from "react-hook-form";
5
import { debounce } from '../../../utils'
5
import styled from "styled-components";
-
 
6
import { axios } from "../../../utils";
6
import { searchEntities } from '../../../services/search'
7
import { addNotification } from "../../../redux/notification/notification.actions";
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import Spinner from "../../../shared/loading-spinner/Spinner";
-
 
9
import ProfileCard from "../../../components/Profile";
8
import ProfileCard from '../../../components/Profile'
10
import SearchList from "../../../components/SearchList";
9
import SearchList from '../../../components/SearchList'
11
 
-
 
12
const StyledSpinnerContainer = styled.div`
10
import TitleSection from '../../../components/TitleSection'
13
  position: absolute;
-
 
14
  left: 0;
-
 
15
  top: 0;
-
 
16
  width: 100%;
-
 
17
  height: 100%;
-
 
18
  background: rgba(255, 255, 255, 0.4);
11
import EmptySection from '../../../shared/empty-section/EmptySection'
19
  display: flex;
-
 
20
  justify-content: center;
12
import Spinner from '../../../shared/loading-spinner/Spinner'
21
  align-items: center;
-
 
22
  z-index: 300;
-
 
23
`;
-
 
24
 
13
 
25
const AppliedJobs = (props) => {
14
const AppliedJobs = ({ addNotification }) => {
26
  // states
-
 
27
  const [appliedJobs, setAppliedJobs] = useState([]);
15
  const [appliedJobs, setAppliedJobs] = useState([])
28
  const [loading, setLoading] = useState(true);
16
  const [loading, setLoading] = useState(true)
Línea 29... Línea 17...
29
 
17
 
30
  useEffect(() => {
18
  useEffect(() => {
31
    fetchAppliedJobs();
-
 
32
    return () => {
-
 
33
      clearTimeout(axiosThrottle);
-
 
34
    };
19
    fetchAppliedJobs()
35
  }, []);
-
 
36
 
-
 
37
  const fetchAppliedJobs = async (searchParam = '') => {
-
 
38
    setLoading(true);
-
 
39
    await axios
-
 
40
      .get(
-
 
41
        "/job/applied-jobs?search=" + searchParam)
-
 
42
      .then((response) => {
-
 
43
        const resData = response.data;
-
 
44
        if (resData.success) {
-
 
45
          setAppliedJobs(resData.data);
-
 
46
        }
-
 
47
      });
-
 
48
    setLoading(false);
-
 
Línea -... Línea 20...
-
 
20
  }, [])
-
 
21
 
-
 
22
  const fetchAppliedJobs = async (searchValue = '') => {
-
 
23
    setLoading(true)
-
 
24
    const response = await searchEntities('job/applied-jobs', searchValue)
-
 
25
 
-
 
26
    if (!response.success) {
-
 
27
      addNotification({ style: 'danger', msg: response.data })
-
 
28
      setLoading(false)
-
 
29
      return
-
 
30
    }
-
 
31
 
-
 
32
    setAppliedJobs(response.data)
Línea -... Línea 33...
-
 
33
    setLoading(false)
Línea 49... Línea 34...
49
  };
34
  }
50
 
35
 
51
 
36
  const handleSearch = (value) => debounce(fetchAppliedJobs(value), 500)
52
 
-
 
53
  return (
37
 
54
    <section className="companies-info" style={{ position: "relative" }}>
38
  return (
55
      <div className="container">
-
 
56
        <SearchList
-
 
57
          title="Empleos aplicados"
39
    <section className="companies-info" style={{ position: 'relative' }}>
58
          fetchCallback={fetchAppliedJobs}
-
 
59
        />
-
 
60
        <div
40
      <div className="container">
61
          className="companies-list"
-
 
62
          id="profiles-container"
-
 
63
          style={{
41
        <TitleSection title={LABELS.PEOPLE_BLOCKED} />
64
            padding: "0 15px",
42
        <SearchList onChange={handleSearch} />
65
          }}
-
 
66
        >
-
 
67
          {appliedJobs.length > 0 ? (
-
 
68
            appliedJobs.map(
43
        <div className="companies-list">
69
              (
-
 
70
                {
-
 
71
                  title,
-
 
72
                  employment_type,
-
 
73
                  last_date_of_application,
-
 
74
                  link_view,
-
 
75
                  link_remove,
44
          {loading && <Spinner />}
76
                },
45
          {(!loading && Boolean(!appliedJobs.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
77
                index
46
          {(!loading && Boolean(appliedJobs.length)) &&
78
              ) => (
47
            appliedJobs.map(({ title, employment_type, link_view, link_remove }, index) =>
79
                <ProfileCard
48
              <ProfileCard
80
                  key={index}
49
                key={index}
81
                  name={title}
50
                name={title}
82
                  status={employment_type}
51
                status={employment_type}
83
                  link_view={link_view}
52
                link_view={link_view}
84
                  link_delete={link_remove}
53
                link_delete={link_remove}
85
                  fetchCallback={fetchAppliedJobs}
-
 
86
                  btnAcceptTitle='Ver oferta'
54
                fetchCallback={fetchAppliedJobs}
87
                  btnCancelTitle='Quitar aplicación'
-
 
88
                />
-
 
89
              )
-
 
90
            )
-
 
91
          ) : (
55
                btnAcceptTitle={LABELS.VIEW_JOB}
92
            <p>No hay resultados</p>
56
                btnCancelTitle={LABELS.JOB_REQUEST_CANCEL}
93
          )}
-
 
94
          {/* <!--product-feed-tab end--> */}
-
 
95
        </div>
-
 
96
      </div>
-
 
97
      {loading && (
-
 
98
        <StyledSpinnerContainer>
57
              />
99
          <Spinner />
58
            )}
100
        </StyledSpinnerContainer>
59
        </div>
101
      )}
-
 
102
    </section>
-
 
Línea 103... Línea 60...
103
  );
60
      </div>
104
};
61
    </section>
105
 
62
  )
Línea 106... Línea 63...
106
// const mapStateToProps = (state) => ({});
63
}