Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7291 stevensc 1
import React, { useState } from 'react'
7480 stevensc 2
import { deleteFeed } from '../../redux/feed/feed.actions'
7427 stevensc 3
import DeleteModal from '../../shared/DeleteModal'
7386 stevensc 4
import CommentSection from './CommentSection'
11225 stevensc 5
import parse from 'html-react-parser'
14867 stevensc 6
import styles from './feedTemplate.module.scss'
7205 stevensc 7
 
11225 stevensc 8
const FeedTemplate = ({ feed }) => {
7205 stevensc 9
 
14867 stevensc 10
	const [displayOption, setDisplayOption] = useState(false)
11225 stevensc 11
	const [showDeleteModal, setShowDeleteModal] = useState(false)
12
	const [isReadMoreActive, setIsReadMoreActive] = useState(false)
13
	const closeModal = () => setShowDeleteModal(false)
7291 stevensc 14
 
11225 stevensc 15
	const readMoreHandler = () => {
16
		setIsReadMoreActive(!isReadMoreActive)
17
	}
7291 stevensc 18
 
11225 stevensc 19
	const htmlParsedText = (fullStringText) => {
20
		const fullText = parse(fullStringText)
21
		if (fullStringText.length > 500) {
22
			const shortenedString = fullStringText.substr(0, 500)
23
			const shortenedText = parse(`${shortenedString}... `)
24
			return (
25
				<React.Fragment>
26
					{isReadMoreActive ? fullText : shortenedText}
27
					<button className='btn py-0 px-1' onClick={readMoreHandler}>
28
						{isReadMoreActive ? ' Leer menos' : ' Leer más'}
29
					</button>
30
				</React.Fragment>
31
			)
32
		} else {
33
			return fullText
34
		}
35
	}
36
 
37
	return (
38
		<>
14867 stevensc 39
			<div className={styles.postContainer}>
40
				< div className="post_topbar" >
41
					<div className="usy-dt">
42
						<a href={feed.owner_url}>
43
							<img src={feed.owner_image} alt="" style={{
44
								width: '50px',
45
								height: 'auto',
46
							}}
47
							/>
48
						</a>
49
						<div className="usy-name">
50
							<a href={feed.owner_url}>
51
								<h3>{feed.owner_name}</h3>
52
							</a>
53
							<span>
54
								{feed.Fowner_time_elapse}
55
							</span>
56
						</div>
57
					</div>
58
					{
59
						feed.feed_delete_url
60
						&&
61
						<div className="cursor-pointer d-flex align-items-center">
62
							<i
63
								className='fa fa-ellipsis-v'
64
								onClick={() => setDisplayOption(!displayOption)}
65
								style={{ fontSize: '1.5rem' }}
66
							/>
67
							<div className={`feed-options ${displayOption ? 'active' : ''}`}>
68
								<ul>
69
									<li>
70
										<button
71
											className="option-btn"
72
											onClick={() => setShowDeleteModal(true)}
73
										>
74
											<i className="fa fa'trash mr-1" />
75
											Borrar
76
										</button>
77
									</li>
78
								</ul>
11225 stevensc 79
							</div>
14867 stevensc 80
						</div>
81
					}
82
				</div >
83
				<div>
84
					<div className="job_descp">
85
						{
86
							feed.showDescription
87
							&&
88
							<div className="show-read-more">
89
								{htmlParsedText(feed.owner_description)}
90
							</div>
91
						}
92
						{feed.owner_file_image &&
93
							<img src={feed.owner_file_image} className="Entradas" />
94
						}
95
						{feed.owner_file_video &&
96
							<video
97
								src={feed.owner_file_video}
98
								controls
99
								poster={feed.owner_file_image_preview}
100
								preload="none"
101
							/>
102
						}
103
						{feed.owner_file_document &&
104
							<a href={feed.owner_file_document} target="_blank" rel="noreferrer">
105
								Descargar
106
							</a>
107
						}
108
						{feed.shared_name &&
109
							<div className="shared-post-bar">
110
								<div className="post-bar">
111
									<div className="post_topbar">
112
										<div className="usy-dt">
113
											<img
114
												src={feed.shared_image}
115
												alt=""
116
												style={{ width: '50px', height: 'auto', }}
117
											/>
118
											<div className="usy-name">
119
												<h3>{feed.shared_name}</h3>
120
												<span>
121
													{feed.shared_time_elapse}
122
												</span>
123
											</div>
124
										</div>
125
									</div>
126
									<div className="job_descp">
127
										<div className="show-read-more">
128
											{htmlParsedText(feed.shared_description)}
129
										</div>
130
										{feed.shared_file_image &&
131
											<img src={feed.shared_file_image} className="Entradas" />
132
										}
133
										{feed.shared_file_video &&
134
											<video
135
												src={feed.shared_file_video}
136
												controls
137
												poster={feed.shared_file_image_preview}
138
												preload="none"
139
											/>
140
										}
141
										{feed.shared_file_document &&
142
											<a href={feed.shared_file_document} target="_blank" rel="noreferrer">
143
												Descargar
144
											</a>
145
										}
146
									</div>
11225 stevensc 147
								</div>
148
							</div>
14867 stevensc 149
						}
150
					</div>
151
				</div>
152
				<div className="job-status-bar">
153
					<ul className="reactions-list">
154
						<li>
11225 stevensc 155
							<button
14867 stevensc 156
								type="button"
157
								id={`btn-comments-${feed.feed_unique}`}
158
								className="btn-indicator"
11225 stevensc 159
							>
14867 stevensc 160
								<i className="fa fa-comments mr-1" />
161
								{feed.owner_shared}
11225 stevensc 162
							</button>
14867 stevensc 163
						</li>
164
						<li>
165
							<button
166
								type="button"
167
								id={`btn-share-${feed.feed_unique}`}
168
								className="btn-indicator"
11225 stevensc 169
							>
14867 stevensc 170
								<i className="fa fa-share flip-horizontal ps-1" />
171
								{feed.owner_shared}
11225 stevensc 172
							</button>
173
						</li>
174
					</ul>
175
				</div>
14867 stevensc 176
				<CommentSection
177
					comments_link_add={feed.comment_add_url}
178
					comments={feed.comments}
179
					owner_image={feed.owner_image}
180
					owner_url={feed.owner_url}
181
				/>
182
 
11225 stevensc 183
			</div>
184
			<DeleteModal
185
				url={feed.feed_delete_url}
186
				isOpen={showDeleteModal}
187
				closeModal={closeModal}
188
				title="Esta seguro de borrar esta publicación?"
189
				action={() => deleteFeed(feed.feed_unique)}
190
				message="La publicación ha sido borrada"
191
			/>
192
		</>
193
	)
194
}
195
export default React.memo(FeedTemplate)