Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5473 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5473 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
3
import parse from 'html-react-parser'
4
import EditIcon from '@mui/icons-material/EditOutlined'
5
import DeleteIcon from '@mui/icons-material/DeleteOutline'
5868 stevensc 6
import { axios } from '../../../../../../../utils'
7
import ConfirmationBox from '../../../../../../../shared/confirmation-box/ConfirmationBox'
5473 stevensc 8
 
5868 stevensc 9
const ExperienceCard = ({
10
  experience,
11
  months,
12
  isEdit = false,
13
  onEdit = () => {},
14
  setExperiences = () => {},
15
}) => {
5473 stevensc 16
  const [isShowModal, setIsShowModal] = useState(false)
17
 
18
  const deleteExperience = async () => {
5868 stevensc 19
    await axios.post(experience.link_delete).then(({ data: response }) => {
20
      if (response.success) return setExperiences(response.data)
21
    })
22
  }
5473 stevensc 23
 
24
  return (
5868 stevensc 25
    <div className="card__items">
5473 stevensc 26
      <div className="card__options-container">
27
        <h4>{experience.title}</h4>
5868 stevensc 28
        {isEdit && (
29
          <div className="card__options-icons position-relative">
30
            <button
31
              className="button-icon"
32
              onClick={() =>
33
                onEdit(
34
                  'Experiencia',
35
                  experience.link_edit,
36
                  experience.description || ' '
37
                )
38
              }
39
            >
5473 stevensc 40
              <EditIcon />
41
            </button>
5868 stevensc 42
            <button
43
              className="button-icon"
44
              onClick={() => setIsShowModal(true)}
45
            >
5473 stevensc 46
              <DeleteIcon />
47
            </button>
48
            <ConfirmationBox
49
              show={isShowModal}
50
              onClose={() => setIsShowModal(false)}
51
              onAccept={deleteExperience}
52
            />
53
          </div>
5868 stevensc 54
        )}
5473 stevensc 55
      </div>
56
      <p>{experience.company}</p>
5868 stevensc 57
      <span>{`${
58
        typeof experience.industry === 'object'
59
          ? experience.industry.name
60
          : experience.industry
61
      } / ${experience.size}`}</span>
5473 stevensc 62
      <span>
63
        {`${months[experience.from_month - 1]} ${experience.from_year}`} -{' '}
5868 stevensc 64
        {experience.to_year
65
          ? `${months[experience.to_month - 1]} ${experience.to_year}`
66
          : 'Actual'}
5473 stevensc 67
      </span>
68
      <p>{experience.formatted_adress}</p>
69
      {experience.description && parse(experience.description)}
70
    </div>
71
  )
72
}
73
 
5868 stevensc 74
export default ExperienceCard