Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3634 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3630 stevensc 1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
3
import parse from "html-react-parser";
4
import SharedContent from './SharedContent';
5
 
6
const FeedContent = ({
7
    showDescription = true,
8
    ownerFileImage,
9
    ownerFileVideo,
10
    ownerFileImagePreview,
11
    ownerFileDocument,
12
    ownerDescription,
13
    isShare,
14
    sharedItem
15
}) => {
16
 
17
    const [isReadMoreActive, setIsReadMoreActive] = useState(false);
18
 
19
    const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)
20
 
21
    const htmlParsedText = (fullStringText) => {
22
        const fullText = parse(fullStringText)
23
        if (fullStringText.length > 500) {
24
            const shortenedString = fullStringText.substr(0, 500);
25
            const shortenedText = parse(`${shortenedString}... `);
26
            return (
27
                <p>
28
                    {isReadMoreActive ? fullText : shortenedText}
29
                    <span className='cursor-pointer' onClick={readMoreHandler}>
30
                        {isReadMoreActive ? " Leer menos" : " Leer más"}
31
                    </span>
32
                </p>
33
            );
34
        }
35
        return <p>{fullText}</p>
36
    };
37
 
38
    return (
39
        <div className="job_descp">
40
            {showDescription &&
41
                <div className="show-read-more">
42
                    {htmlParsedText(ownerDescription)}
43
                </div>
44
            }
45
            {ownerFileImage &&
46
                <img src={ownerFileImage} className="Entradas" />
47
            }
48
            {ownerFileVideo &&
49
                <video
50
                    src={ownerFileVideo}
51
                    controls
52
                    poster={ownerFileImagePreview}
53
                    preload="none"
54
                />
55
            }
56
            {ownerFileDocument &&
57
                <a href={ownerFileDocument} target="_blank" rel="noreferrer">
58
                    Descargar
59
                </a>
60
            }
61
            {isShare &&
62
                <SharedContent
63
                    name={sharedItem.name}
64
                    image={sharedItem.image}
65
                    timeElapse={sharedItem.time_elapse}
66
                    description={sharedItem.description}
67
                    fileVideo={sharedItem.file_video}
68
                    fileImagePreview={sharedItem.file_image_preview}
69
                    fileImage={sharedItem.file_image}
70
                    fileDocument={sharedItem.file_document}
71
                />
72
            }
73
        </div>
74
    )
75
}
76
 
77
export default FeedContent