Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7272 | Rev 7279 | 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;
7272 stevensc 18
  h3 {
19
    font-size: 1.1rem;
20
    font-weight: 600;
21
    color: var(--title-color);
22
  }
23
  span {
24
    font-weight: 600;
25
    color: var(--subtitle-color);
26
  }
27
  .info {
28
    align-items: center;
29
    display: inline-flex;
30
    gap: 0.5rem;
31
  }
32
  .name {
33
    display: flex;
34
    flex-direction: column;
35
    gap: 0.5rem;
36
  }
7273 stevensc 37
  .details {
38
    display: flex;
39
    align-items: center;
40
    justify-content: space-between;
41
    gap: 0.5rem;
42
  }
7271 stevensc 43
`
44
 
45
const StyledHeart = styled(Favorite)`
46
  animation: heartBeatAnimation 0.2s linear;
47
 
48
  @keyframes heartBeatAnimation {
49
    0% {
50
      transform: scale(1);
51
    }
52
    50% {
53
      transform: scale(1.3);
54
    }
55
    100% {
56
      transform: scale(1);
57
    }
7268 stevensc 58
  }
7271 stevensc 59
`
60
 
61
const StyledHeartOutline = styled(FavoriteBorder)`
62
  animation: heartBeatAnimation 0.2s linear;
63
 
7268 stevensc 64
  @keyframes heartBeatAnimation {
65
    0% {
66
      transform: scale(1);
67
    }
68
    50% {
69
      transform: scale(1.3);
70
    }
71
    100% {
72
      transform: scale(1);
73
    }
74
  }
75
`
76
 
77
const Description = ({
78
  jobId,
79
  companyId,
80
  companyImage,
81
  jobTitle,
82
  companyName,
83
  timeElapsed,
84
  location,
85
  jobSaved,
86
  lastDateOfApplication,
87
  employmentType,
88
  jobCategory,
89
  jobDescription,
90
  jobSkills,
91
  totalApplications,
92
  jobVisits,
93
}) => {
94
  const [isJobSaved, setIsJobSaved] = useState(jobSaved !== 'job-save')
7271 stevensc 95
  const dispatch = useDispatch()
7268 stevensc 96
 
97
  const handleClickFollow = () => {
98
    setIsJobSaved(!isJobSaved)
99
    likeHandler()
100
  }
101
 
102
  const likeHandler = () => {
103
    axios
104
      .post(`/job/${isJobSaved ? 'remove-' : ''}save-job/${jobId}`)
7271 stevensc 105
      .then((response) => {
106
        const { success } = response.data
107
 
108
        if (!success) {
7268 stevensc 109
          setIsJobSaved((currentState) => !currentState)
7271 stevensc 110
          dispatch(
111
            addNotification({
112
              style: 'danger',
113
              msg: 'Ha ocurrido un error, por favor intente más tarde',
114
            })
115
          )
7268 stevensc 116
        }
117
      })
118
  }
119
 
120
  return (
7271 stevensc 121
    <StyledContainer>
7272 stevensc 122
      <div className="info">
7271 stevensc 123
        <Avatar
124
          src={`/storage/type/company/code/${companyId}/${
125
            companyImage ? `filename/${companyImage}` : ''
126
          }`}
127
          sx={{ width: '50px', height: '50px' }}
128
        />
7272 stevensc 129
 
130
        <div className="name">
7271 stevensc 131
          <h3>{jobTitle}</h3>
132
          <p>{companyName}</p>
133
          <span>
134
            <AccessTimeIcon />
135
            Posteado hace {timeElapsed}
136
          </span>
7268 stevensc 137
        </div>
138
      </div>
139
 
7271 stevensc 140
      <div className="details">
141
        <span>
142
          <LocationOnIcon />
143
          {location}
144
        </span>
145
 
146
        <span>
147
          {isJobSaved ? (
148
            <StyledHeart onClick={handleClickFollow} />
149
          ) : (
150
            <StyledHeartOutline onClick={handleClickFollow} />
7268 stevensc 151
          )}
7271 stevensc 152
          Última aplicación : {lastDateOfApplication}
153
        </span>
7268 stevensc 154
      </div>
7271 stevensc 155
 
7272 stevensc 156
      <div className="job">
7271 stevensc 157
        <h3>{employmentType}</h3>
158
        <h3>{jobCategory}</h3>
159
        <div>{parse(jobDescription)}</div>
160
 
161
        {!!jobSkills.length && (
162
          <ul className="skill-tags">
163
            {jobSkills.map((skill, index) => (
164
              <li key={index}>
165
                <span>{skill}</span>
166
              </li>
167
            ))}
168
          </ul>
169
        )}
170
        <span>
171
          <EmailIcon />
172
          Solicitantes {totalApplications}
173
        </span>
7268 stevensc 174
      </div>
7271 stevensc 175
 
176
      <span>
177
        <VisibilityIcon /> Visto {jobVisits}
178
      </span>
179
    </StyledContainer>
7268 stevensc 180
  )
181
}
182
 
7271 stevensc 183
export default Description