Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

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