Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5496 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5475 stevensc 1
import React, { useState, useEffect } from 'react'
2
import parse from 'html-react-parser'
5499 stevensc 3
 
5475 stevensc 4
import EditIcon from '@mui/icons-material/Edit'
5
import DeleteIcon from '@mui/icons-material/Delete'
6
import IconButton from '@mui/material/IconButton'
5499 stevensc 7
import ConfirmModal from '../../../shared/confirm-modal/ConfirmModal'
5475 stevensc 8
 
5476 stevensc 9
const Experience = ({ experience, months = [], onDelete, onEdit, isEdit }) => {
5475 stevensc 10
  const [isConfirmationBoxShow, setIsConfirmationBoxShow] = useState(false)
11
  const [monthOptions, setMonthOptions] = useState({})
12
 
13
  useEffect(() => {
14
    setMonthOptions(
15
      months.reduce((obj, item, i) => ({ ...obj, [i + 1]: item }), {})
16
    )
17
  }, [months, monthOptions])
18
 
19
  const toggleConfirmModal = () =>
20
    setIsConfirmationBoxShow(!isConfirmationBoxShow)
21
 
22
  return (
23
    <>
24
      <div className="experience-item">
25
        <div className="experience-item-header">
5481 stevensc 26
          <h3>{experience.company}</h3>
5476 stevensc 27
          {isEdit && (
5496 stevensc 28
            <div className="d-inline-flex align-items-center gap-2">
5476 stevensc 29
              <IconButton onClick={() => onEdit(experience.link_edit)}>
5478 stevensc 30
                <EditIcon />
5476 stevensc 31
              </IconButton>
32
              <IconButton onClick={toggleConfirmModal}>
5478 stevensc 33
                <DeleteIcon />
5476 stevensc 34
              </IconButton>
35
            </div>
36
          )}
5475 stevensc 37
        </div>
5481 stevensc 38
        <h4>{experience.title}</h4>
5475 stevensc 39
        <p>
40
          {`${monthOptions[experience.from_month]} ${experience.from_year} - ${
5478 stevensc 41
            experience.is_current === 'y'
42
              ? 'Actual'
43
              : `${monthOptions[experience.to_month]} ${experience.to_year}`
44
          }`}
5475 stevensc 45
        </p>
46
        <p>{`${experience.industry.name || experience.industry} / ${
47
          experience.size
48
        }`}</p>
49
        <p>{experience.formatted_address}</p>
50
        {experience.description && parse(experience.description)}
51
      </div>
5499 stevensc 52
      <ConfirmModal
5475 stevensc 53
        show={isConfirmationBoxShow}
54
        onClose={toggleConfirmModal}
55
        onAccept={() => onDelete(experience.link_delete)}
56
      />
57
    </>
58
  )
59
}
60
 
61
export default Experience