Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4817 | Rev 4819 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4817 Rev 4818
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React, { useState } from 'react'
2
import React, { useEffect, useState } from 'react'
3
import { axios } from '../../utils'
3
import { axios } from '../../utils'
4
import { addNotification } from '../../redux/notification/notification.actions'
4
import { addNotification } from '../../redux/notification/notification.actions'
5
import parse from 'html-react-parser'
5
import parse from 'html-react-parser'
Línea 6... Línea 6...
6
 
6
 
Línea 16... Línea 16...
16
import SendOutlinedIcon from '@mui/icons-material/SendOutlined'
16
import SendOutlinedIcon from '@mui/icons-material/SendOutlined'
17
import AccessTimeIcon from '@mui/icons-material/AccessTime'
17
import AccessTimeIcon from '@mui/icons-material/AccessTime'
Línea 18... Línea 18...
18
 
18
 
19
// Styles
19
// Styles
-
 
20
import '../templates/linkedin/Feed/Feed.scss'
Línea 20... Línea 21...
20
import '../templates/linkedin/Feed/Feed.scss'
21
import FeedCommentSection from '../components/feed/feed-comment/FeedCommentSection'
21
 
22
 
22
export default function PostView({ post = {
23
export default function PostView({ post = {
23
    url: "",
24
    url: "",
24
    file: "imagengrupo.png",
25
    file: "imagengrupo.png",
25
    comments_url: "/post/344ccca7-6260-4564-93cc-85ed7682bec2/comments",
26
    comments_url: "/post/344ccca7-6260-4564-93cc-85ed7682bec2/comments",
26
    comments_add_url: "/post/344ccca7-6260-4564-93cc-85ed7682bec2/comments/add"
27
    comments_add_url: "/post/344ccca7-6260-4564-93cc-85ed7682bec2/comments/add"
27
}
28
}
28
}) {
29
}) {
-
 
30
    const [isLiked, setIsLiked] = useState(post.is_liked)
29
    const [isLiked, setIsLiked] = useState(post.is_liked)
31
    const [externalShare, setExternalShare] = useState(post.total_share_external)
30
    const [externalShare, setExternalShare] = useState(post.total_share_external)
32
    const [comments, setComments] = useState([])
Línea 31... Línea 33...
31
    const [isReadMoreActive, setIsReadMoreActive] = useState(false)
33
    const [isReadMoreActive, setIsReadMoreActive] = useState(false)
Línea 32... Línea 34...
32
    const [showComments, setShowComments] = useState(false)
34
    const [showComments, setShowComments] = useState(false)
33
 
35
 
-
 
36
    const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)
-
 
37
 
-
 
38
    const displayCommentSection = () => {
-
 
39
        axios.get(post.comments_url)
-
 
40
            .then(({ data: response }) => {
-
 
41
                if (!response.success) {
34
    const readMoreHandler = () => setIsReadMoreActive(!isReadMoreActive)
42
                    addNotification({ style: 'danger', msg: response.data })
-
 
43
                    return
35
 
44
                }
Línea 36... Línea 45...
36
    const displayCommentSection = () => {
45
 
37
        axios.get(post.comments_url)
46
                setComments(response.data)
38
        setShowComments(!showComments)
47
            })
Línea 74... Línea 83...
74
            )
83
            )
75
        }
84
        }
76
        return <p>{fullText}</p>
85
        return <p>{fullText}</p>
77
    }
86
    }
Línea -... Línea 87...
-
 
87
 
-
 
88
    useEffect(() => {
-
 
89
        if (comments.length > 0) setShowComments(!showComments)
-
 
90
    }, [comments])
-
 
91
 
78
 
92
 
79
    return (
93
    return (
80
        <div className="container">
94
        <div className="container">
81
            <div className="d-flex flex-column flex-md-row" style={{ gap: '1rem' }}>
95
            <div className="d-flex flex-column flex-md-row" style={{ gap: '1rem' }}>
82
                <div className="col-12 col-md-8 p-0">
96
                <div className="col-12 col-md-8 p-0">
Línea 94... Línea 108...
94
                                    </div>
108
                                    </div>
95
                                </div>
109
                                </div>
96
                            </div>
110
                            </div>
97
                            {post.description && htmlParsedText(post.description)}
111
                            {post.description && htmlParsedText(post.description)}
98
                        </div>
112
                        </div>
99
                        <div className="px-3 d-flex align-items-center justify-content-between">
113
                        <div className="px-3 d-flex align-items-center justify-content-between" style={{ gap: '5px' }}>
100
                            <div className="d-inline-flex align-items-center" style={{ gap: '5px' }}>
-
 
101
                                {!!externalShare && <span>{`${externalShare} enviados`}</span>}
114
                            {!!externalShare && <span>{`${externalShare} enviados`}</span>}
102
                            </div>
115
                        </div>
103
                            <div className='feed__buttons'>
116
                        <div className='feed__buttons'>
104
                                <InputOption
117
                            <InputOption
105
                                    Icon={isLiked ? ThumbUpAltIcon : ThumbUpAltOutlinedIcon}
118
                                Icon={isLiked ? ThumbUpAltIcon : ThumbUpAltOutlinedIcon}
106
                                    title='Like'
119
                                title='Like'
107
                                    color={isLiked ? '#7405f9' : 'gray'}
120
                                color={isLiked ? '#7405f9' : 'gray'}
108
                                    onClick={() => handleLike(isLiked ? post.unlike_url : post.like_url)}
121
                                onClick={() => handleLike(isLiked ? post.unlike_url : post.like_url)}
109
                                />
122
                            />
110
                                <InputOption
123
                            <InputOption
111
                                    Icon={ChatOutlinedIcon}
124
                                Icon={ChatOutlinedIcon}
112
                                    title='Comment'
125
                                title='Comment'
113
                                    color='gray'
126
                                color='gray'
114
                                    onClick={displayCommentSection}
127
                                onClick={displayCommentSection}
115
                                />
128
                            />
116
                                <ExternalShareButton />
129
                            <ExternalShareButton />
-
 
130
                        </div>
-
 
131
                        <div className='px-2 pb-2'>
-
 
132
                            <FeedCommentSection
-
 
133
                                feedId={post.uuid}
-
 
134
                                addUrl={post.comments_add_url}
-
 
135
                                comments={comments}
-
 
136
                                isShow={showComments}
117
                            </div>
137
                            />
118
                        </div>
138
                        </div>
119
                    </div>
139
                    </div>
120
                </div>
140
                </div>
121
                <div className="col-12 col-md-4 p-0">
141
                <div className="col-12 col-md-4 p-0">
122
                    <HomeNews currentPost={post.uuid} />
142
                    <HomeNews currentPost={post.uuid} />