Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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