Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7271 | Ir a la última revisión | | Ultima modificación | Ver Log |

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