Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5822 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useState } from "react"
3
import parse from "html-react-parser"
4
import styled from "styled-components"
5
import { axios } from "../../../../utils"
6
import { addNotification } from "../../../../redux/notification/notification.actions"
7
import { connect } from "react-redux"
8
 
9
const StyledHeart = styled.a`
10
  .heart.animate {
11
    animation: heartBeatAnimation 0.2s linear
12
  }
13
  @keyframes heartBeatAnimation {
14
    0% {
15
      transform: scale(1)
16
    }
17
    50% {
18
      transform: scale(1.3)
19
    }
20
    100% {
21
      transform: scale(1)
22
    }
23
  }
24
`
25
 
26
const Description = ({
27
  jobId,
28
  companyId,
29
  companyImage,
30
  jobTitle,
31
  companyName,
32
  timeElapsed,
33
  location,
34
  jobSaved,
35
  lastDateOfApplication,
36
  employmentType,
37
  jobCategory,
38
  jobDescription,
39
  jobSkills,
40
  totalApplications,
41
  jobVisits,
42
  addNotification //redux destructuring
43
}) => {
44
  const [animateHeart, setAnimateHeart] = useState(false)
45
  const [isJobSaved, setIsJobSaved] = useState(jobSaved === "job-save" ? false : true)
46
 
47
  const handleClickFollow = () => {
48
    setAnimateHeart(true)
49
    setIsJobSaved(!isJobSaved)
50
    likeHandler()
51
  }
52
 
53
  const likeHandler = () => {
54
    axios.post(`/job/${isJobSaved ? "remove-" : ""}save-job/${jobId}`)
55
      .then(({ data: response }) => {
56
        if (!response.success) {
57
          setIsJobSaved((currentState) => !currentState)
58
          addNotification({ style: "danger", msg: "Ha ocurrido un error, por favor intente más tarde" })
59
          return
60
        }
61
 
62
      })
63
  }
64
 
65
  return (
66
    <div className='description'>
67
      <div className='header'>
68
        <div className="usy-dt">
69
          <img
70
            style={{ width: "50px", height: "auto" }}
71
            src={`/storage/type/company/code/${companyId}/${companyImage ? `filename/${companyImage}` : ""}`}
72
            alt=""
73
          />
74
          <div className="usy-name">
75
            <h3>{jobTitle}</h3>
76
            <p>{companyName}</p>
77
            <span>
78
              <img src="/images/clock.png" alt="" />
79
              Posteado hace {timeElapsed}
80
            </span>
81
          </div>
82
        </div>
83
      </div>
84
      <div className='infoContainer'>
85
        <div className='descpContainer'>
86
          <ul className='locationContainer'>
87
            <li>
88
              <img src="/images/icon9.png" alt="" />
89
              <span>{location}</span>
90
            </li>
91
          </ul>
92
          <ul className='likeContainer'>
93
            <li>
94
              <StyledHeart
95
                href="#"
96
                title=""
97
                className="btn-remove-saved-job"
98
                onClick={(e) => {
99
                  e.preventDefault()
100
                  handleClickFollow()
101
                }}
102
                onAnimationEnd={() => setAnimateHeart(false)}
103
              >
104
                <i
105
                  className={`la la-heart${isJobSaved ? "" : "-o"} heart ${animateHeart ? "animate" : ""}`}
106
                  style={{ color: "#53d690" }}
107
                />
108
              </StyledHeart>
109
            </li>
110
            <li>
111
              <span>Última aplicación : {lastDateOfApplication}</span>
112
            </li>
113
          </ul>
114
        </div>
115
 
116
        <div className="job_descp accountnone">
117
          <ul className="job-dt">
118
            <li>
119
              <a href="#">{employmentType}</a>
120
            </li>
121
            <li>
122
              <a href="#">{jobCategory}</a>
123
            </li>
124
          </ul>
125
          <div className="show-read-more">{parse(jobDescription)}</div>
126
          {jobSkills.length &&
127
            <ul className="skill-tags">
128
              {jobSkills.map((jobSkill, index) =>
129
                <li key={index}>
130
                  <a href="#" title="">
131
                    {jobSkill}
132
                  </a>
133
                </li>
134
              )}
135
            </ul>}
136
        </div>
137
      </div>
138
      <div className="job-status-bar btm-line">
139
        <ul className="d-inline-flex" style={{ gap: '.5rem' }}>
140
          <li>
141
            <i className="fa fa-address-card-o" />
142
            <span>{`Solicitantes ${totalApplications}`}</span>
143
          </li>
144
        </ul>
145
        <a>
146
          <i className="fas fa-eye"></i>Visto {jobVisits}
147
        </a>
148
      </div>
149
    </div>
150
  )
151
}
152
 
153
const mapDispatchToProps = {
154
  addNotification: (notification) => addNotification(notification),
155
}
156
 
157
export default connect(null, mapDispatchToProps)(Description)