Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7268 | Rev 7272 | Ir a la última revisión | | Comparar con el anterior | 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'
7271 stevensc 3
import { useDispatch } from 'react-redux'
7268 stevensc 4
import { addNotification } from '../../redux/notification/notification.actions'
5
import parse from 'html-react-parser'
7271 stevensc 6
import Avatar from '@mui/material/Avatar'
7
import { Favorite, FavoriteBorder } from '@mui/icons-material'
8
import AccessTimeIcon from '@mui/icons-material/AccessTime'
9
import LocationOnIcon from '@mui/icons-material/LocationOn'
10
import VisibilityIcon from '@mui/icons-material/Visibility'
11
import EmailIcon from '@mui/icons-material/Email'
12
 
7268 stevensc 13
import styled from 'styled-components'
7271 stevensc 14
import WidgetLayout from '../widgets/WidgetLayout'
7268 stevensc 15
 
7271 stevensc 16
const StyledContainer = styled(WidgetLayout)`
17
  padding: 1rem;
18
`
19
 
20
const StyledHeart = styled(Favorite)`
21
  animation: heartBeatAnimation 0.2s linear;
22
 
23
  @keyframes heartBeatAnimation {
24
    0% {
25
      transform: scale(1);
26
    }
27
    50% {
28
      transform: scale(1.3);
29
    }
30
    100% {
31
      transform: scale(1);
32
    }
7268 stevensc 33
  }
7271 stevensc 34
`
35
 
36
const StyledHeartOutline = styled(FavoriteBorder)`
37
  animation: heartBeatAnimation 0.2s linear;
38
 
7268 stevensc 39
  @keyframes heartBeatAnimation {
40
    0% {
41
      transform: scale(1);
42
    }
43
    50% {
44
      transform: scale(1.3);
45
    }
46
    100% {
47
      transform: scale(1);
48
    }
49
  }
50
`
51
 
52
const Description = ({
53
  jobId,
54
  companyId,
55
  companyImage,
56
  jobTitle,
57
  companyName,
58
  timeElapsed,
59
  location,
60
  jobSaved,
61
  lastDateOfApplication,
62
  employmentType,
63
  jobCategory,
64
  jobDescription,
65
  jobSkills,
66
  totalApplications,
67
  jobVisits,
68
}) => {
69
  const [isJobSaved, setIsJobSaved] = useState(jobSaved !== 'job-save')
7271 stevensc 70
  const dispatch = useDispatch()
7268 stevensc 71
 
72
  const handleClickFollow = () => {
73
    setIsJobSaved(!isJobSaved)
74
    likeHandler()
75
  }
76
 
77
  const likeHandler = () => {
78
    axios
79
      .post(`/job/${isJobSaved ? 'remove-' : ''}save-job/${jobId}`)
7271 stevensc 80
      .then((response) => {
81
        const { success } = response.data
82
 
83
        if (!success) {
7268 stevensc 84
          setIsJobSaved((currentState) => !currentState)
7271 stevensc 85
          dispatch(
86
            addNotification({
87
              style: 'danger',
88
              msg: 'Ha ocurrido un error, por favor intente más tarde',
89
            })
90
          )
7268 stevensc 91
        }
92
      })
93
  }
94
 
95
  return (
7271 stevensc 96
    <StyledContainer>
97
      <div className="user-info">
98
        <Avatar
99
          src={`/storage/type/company/code/${companyId}/${
100
            companyImage ? `filename/${companyImage}` : ''
101
          }`}
102
          sx={{ width: '50px', height: '50px' }}
103
        />
104
        <div className="user-name">
105
          <h3>{jobTitle}</h3>
106
          <p>{companyName}</p>
107
          <span>
108
            <AccessTimeIcon />
109
            Posteado hace {timeElapsed}
110
          </span>
7268 stevensc 111
        </div>
112
      </div>
113
 
7271 stevensc 114
      <div className="details">
115
        <span>
116
          <LocationOnIcon />
117
          {location}
118
        </span>
119
 
120
        <span>
121
          {isJobSaved ? (
122
            <StyledHeart onClick={handleClickFollow} />
123
          ) : (
124
            <StyledHeartOutline onClick={handleClickFollow} />
7268 stevensc 125
          )}
7271 stevensc 126
          Última aplicación : {lastDateOfApplication}
127
        </span>
7268 stevensc 128
      </div>
7271 stevensc 129
 
130
      <div className="job-info">
131
        <h3>{employmentType}</h3>
132
        <h3>{jobCategory}</h3>
133
        <div>{parse(jobDescription)}</div>
134
 
135
        {!!jobSkills.length && (
136
          <ul className="skill-tags">
137
            {jobSkills.map((skill, index) => (
138
              <li key={index}>
139
                <span>{skill}</span>
140
              </li>
141
            ))}
142
          </ul>
143
        )}
144
        <span>
145
          <EmailIcon />
146
          Solicitantes {totalApplications}
147
        </span>
7268 stevensc 148
      </div>
7271 stevensc 149
 
150
      <span>
151
        <VisibilityIcon /> Visto {jobVisits}
152
      </span>
153
    </StyledContainer>
7268 stevensc 154
  )
155
}
156
 
7271 stevensc 157
export default Description