Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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