Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

/* eslint-disable react/prop-types */
import React, { useState } from 'react'
import parse from "html-react-parser";
import SharedContent from './SharedContent';

const FeedContent = ({
    showDescription = true,
    ownerFileImage,
    ownerFileVideo,
    ownerFileImagePreview,
    ownerFileDocument,
    ownerDescription,
    isShare,
    sharedItem
}) => {

    const [isReadMoreActive, setIsReadMoreActive] = useState(false);

    const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)

    const htmlParsedText = (fullStringText) => {
        const fullText = parse(fullStringText)
        if (fullStringText.length > 500) {
            const shortenedString = fullStringText.substr(0, 500);
            const shortenedText = parse(`${shortenedString}... `);
            return (
                <p>
                    {isReadMoreActive ? fullText : shortenedText}
                    <span className='cursor-pointer' onClick={readMoreHandler}>
                        {isReadMoreActive ? " Leer menos" : " Leer más"}
                    </span>
                </p>
            );
        }
        return <p>{fullText}</p>
    };

    return (
        <div className="job_descp">
            {showDescription &&
                <div className="show-read-more">
                    {htmlParsedText(ownerDescription)}
                </div>
            }
            {ownerFileImage &&
                <img src={ownerFileImage} className="Entradas" />
            }
            {ownerFileVideo &&
                <video
                    src={ownerFileVideo}
                    controls
                    poster={ownerFileImagePreview}
                    preload="none"
                />
            }
            {ownerFileDocument &&
                <a href={ownerFileDocument} target="_blank" rel="noreferrer">
                    Descargar
                </a>
            }
            {isShare &&
                <SharedContent
                    name={sharedItem.name}
                    image={sharedItem.image}
                    timeElapse={sharedItem.time_elapse}
                    description={sharedItem.description}
                    fileVideo={sharedItem.file_video}
                    fileImagePreview={sharedItem.file_image_preview}
                    fileImage={sharedItem.file_image}
                    fileDocument={sharedItem.file_document}
                />
            }
        </div>
    )
}

export default FeedContent