Rev 7066 | Rev 11257 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect, useState } from 'react'
const EditItem = ({
title,
showModal,
data
}) => {
const [type, setType] = useState('text');
useEffect(() => {
if (Array.isArray(data)) {
setType("list")
}
}, [data]);
return (
<div className="user-profile-ov">
<h3>
{title}
<button
className="btn btn-degrees-edit"
onClick={() => showModal(title)}
>
<i className="fa fa-pencil"></i>
</button>
</h3>
{
type === "list"
?
<ul>
{
data.map((element, index) => {
if (typeof element === "string") {
return (
<li key={index}>
{element}
</li>
)
}
return (
<li key={element.value}>
{element.label}
</li>
)
})
}
</ul>
:
<p>
{
data !== null
? data
: ''
}
</p>
}
</div>
)
}
export default EditItem