| 3361 |
stevensc |
1 |
/* eslint-disable react/prop-types */
|
| 3810 |
stevensc |
2 |
import React, { useState, useRef } from 'react'
|
| 1 |
www |
3 |
import parse from "html-react-parser";
|
|
|
4 |
import moment from 'moment'
|
| 3363 |
stevensc |
5 |
import { BiShareAlt } from 'react-icons/bi'
|
| 3470 |
stevensc |
6 |
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton } from 'react-share';
|
| 3810 |
stevensc |
7 |
import { addNotification } from '../../redux/notification/notification.actions'
|
|
|
8 |
import { useDispatch } from 'react-redux'
|
| 4064 |
stevensc |
9 |
import { axios } from '../../utils';
|
| 4093 |
stevensc |
10 |
import HomeNews from '../components/home-section/HomeNews';
|
| 3361 |
stevensc |
11 |
|
|
|
12 |
export default function PostView({ post = {} }) {
|
|
|
13 |
|
| 3810 |
stevensc |
14 |
const [shareUrl, setShareUrl] = useState()
|
|
|
15 |
const dispatch = useDispatch()
|
|
|
16 |
|
|
|
17 |
const getShareUrl = new Promise((resolve, reject) => {
|
|
|
18 |
axios.get(post.share_external_url)
|
|
|
19 |
.then(({ data }) => {
|
|
|
20 |
if (!data.success) {
|
|
|
21 |
dispatch(addNotification({ style: 'danger', msg: data.data }))
|
|
|
22 |
setShareOptions(false)
|
|
|
23 |
return reject(data.data)
|
|
|
24 |
}
|
|
|
25 |
setShareUrl(data.data)
|
|
|
26 |
return resolve(data.data)
|
|
|
27 |
})
|
|
|
28 |
.catch((err) => reject(err))
|
|
|
29 |
});
|
|
|
30 |
|
| 1 |
www |
31 |
const baseUrl = `/storage/type/post/code/${post.uuid}/filename/`
|
| 3361 |
stevensc |
32 |
const shareContainer = useRef(null)
|
|
|
33 |
const [shareOptions, setShareOptions] = useState(false)
|
|
|
34 |
|
| 1 |
www |
35 |
return (
|
| 3760 |
stevensc |
36 |
<div className="container">
|
| 4096 |
stevensc |
37 |
<div className="d-flex flex-column flex-md-row" style={{ gap: '1rem' }}>
|
| 4093 |
stevensc |
38 |
<div className="col-12 col-md-8 peopleYouMayKnow">
|
|
|
39 |
<div className="job_descp">
|
|
|
40 |
<img
|
|
|
41 |
alt={post.title}
|
|
|
42 |
src={baseUrl + post.image}
|
|
|
43 |
className="Entradas"
|
| 4097 |
stevensc |
44 |
style={{objectFit: 'contain'}}
|
| 4093 |
stevensc |
45 |
/>
|
| 1 |
www |
46 |
</div>
|
| 4093 |
stevensc |
47 |
<div className="job-status-bar">
|
|
|
48 |
<ul className="reactions-list">
|
|
|
49 |
<li className="position-relative">
|
|
|
50 |
<button
|
|
|
51 |
type="button"
|
|
|
52 |
className="btn-indicator"
|
|
|
53 |
onClick={() => setShareOptions(!shareOptions)}
|
|
|
54 |
>
|
|
|
55 |
<BiShareAlt />
|
|
|
56 |
</button>
|
|
|
57 |
{shareOptions &&
|
|
|
58 |
<div className="ext_share post" ref={shareContainer}>
|
|
|
59 |
<FacebookShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
60 |
<FacebookIcon size={32} round />
|
|
|
61 |
</FacebookShareButton>
|
|
|
62 |
<TwitterShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
63 |
<TwitterIcon size={32} round />
|
|
|
64 |
</TwitterShareButton>
|
|
|
65 |
<TelegramShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
66 |
<TelegramIcon size={32} round />
|
|
|
67 |
</TelegramShareButton>
|
|
|
68 |
<WhatsappShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
69 |
<WhatsappIcon size={32} round />
|
|
|
70 |
</WhatsappShareButton>
|
|
|
71 |
<RedditShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
72 |
<RedditIcon size={32} round />
|
|
|
73 |
</RedditShareButton>
|
|
|
74 |
<EmailShareButton beforeOnClick={() => getShareUrl} url={shareUrl}>
|
|
|
75 |
<EmailIcon size={32} round />
|
|
|
76 |
</EmailShareButton>
|
|
|
77 |
</div>
|
|
|
78 |
}
|
|
|
79 |
</li>
|
|
|
80 |
</ul>
|
|
|
81 |
</div>
|
| 4094 |
stevensc |
82 |
<div className="post_topbar mt-3" >
|
| 4093 |
stevensc |
83 |
<div className="usy-dt">
|
|
|
84 |
<div className="usy-name">
|
|
|
85 |
<h3>{post.title}</h3>
|
|
|
86 |
<span>
|
|
|
87 |
{moment(post.date).format('DD-MM-YYYY')}
|
|
|
88 |
</span>
|
| 3761 |
stevensc |
89 |
</div>
|
|
|
90 |
</div>
|
| 4093 |
stevensc |
91 |
</div >
|
|
|
92 |
<div className="job_descp">
|
|
|
93 |
<div className="show-read-more">
|
|
|
94 |
{parse(post.description)}
|
|
|
95 |
</div>
|
| 3760 |
stevensc |
96 |
</div>
|
| 1 |
www |
97 |
</div>
|
| 4093 |
stevensc |
98 |
<div className="col-12 col-md-4">
|
|
|
99 |
<HomeNews />
|
|
|
100 |
</div>
|
|
|
101 |
</div>
|
|
|
102 |
</div >
|
| 1 |
www |
103 |
)
|
|
|
104 |
}
|