3361 |
stevensc |
1 |
/* eslint-disable react/prop-types */
|
|
|
2 |
import React, { useState } 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'
|
3361 |
stevensc |
6 |
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookMessengerIcon, FacebookMessengerShareButton, FacebookShareButton, PinterestIcon, PinterestShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TumblrIcon, TumblrShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton, WorkplaceIcon, WorkplaceShareButton } from 'react-share';
|
|
|
7 |
import { useRef } from 'react';
|
|
|
8 |
|
|
|
9 |
export default function PostView({ post = {} }) {
|
|
|
10 |
|
1 |
www |
11 |
const baseUrl = `/storage/type/post/code/${post.uuid}/filename/`
|
3361 |
stevensc |
12 |
const shareContainer = useRef(null)
|
|
|
13 |
const [shareOptions, setShareOptions] = useState(false)
|
|
|
14 |
|
1 |
www |
15 |
return (
|
3361 |
stevensc |
16 |
<div className='container'>
|
1 |
www |
17 |
<div
|
|
|
18 |
className='row p-2 m-2'
|
3361 |
stevensc |
19 |
style={{ backgroundColor: 'white' }}
|
1 |
www |
20 |
>
|
3361 |
stevensc |
21 |
<div className='col-md-6 col-sm-12 col-12'>
|
1 |
www |
22 |
<div className="card">
|
3361 |
stevensc |
23 |
<img className="card-img-top" src={baseUrl + post.image} alt={post.title} />
|
1 |
www |
24 |
</div>
|
|
|
25 |
</div>
|
3361 |
stevensc |
26 |
<div className='col-md-6 col-sm-12 col-12 d-flex align-items-center position-relative'>
|
1 |
www |
27 |
<div className="card border-0">
|
|
|
28 |
<div className="card-body">
|
|
|
29 |
<h1 className="card-title font-weight-bold border-bottom">{post.title}</h1>
|
|
|
30 |
<p> {moment(post.date).format('DD-MM-YYYY')} </p>
|
|
|
31 |
<p className="card-text">
|
|
|
32 |
{parse(post.description)}
|
|
|
33 |
</p>
|
|
|
34 |
{
|
3361 |
stevensc |
35 |
!!post.file &&
|
|
|
36 |
<a href={baseUrl + post.file} target='_blank' className="btn btn-primary mt-2" rel="noreferrer">
|
|
|
37 |
<i className="fa fa-file" /> Ver adjunto
|
|
|
38 |
</a>
|
1 |
www |
39 |
}
|
|
|
40 |
</div>
|
|
|
41 |
</div>
|
3361 |
stevensc |
42 |
<button
|
3363 |
stevensc |
43 |
className="btn p-0 position-absolute"
|
3361 |
stevensc |
44 |
onClick={() => setShareOptions(!shareOptions)}
|
3363 |
stevensc |
45 |
style={{ right: '1rem', top: '0' }}
|
3361 |
stevensc |
46 |
>
|
3363 |
stevensc |
47 |
<BiShareAlt />
|
3361 |
stevensc |
48 |
</button>
|
|
|
49 |
{
|
|
|
50 |
shareOptions &&
|
3363 |
stevensc |
51 |
<div className="ext_share post" ref={shareContainer}>
|
3361 |
stevensc |
52 |
<FacebookShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
53 |
<FacebookIcon size={32} round />
|
|
|
54 |
</FacebookShareButton>
|
|
|
55 |
<FacebookMessengerShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
56 |
<FacebookMessengerIcon size={32} round />
|
|
|
57 |
</FacebookMessengerShareButton>
|
|
|
58 |
<TwitterShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
59 |
<TwitterIcon size={32} round />
|
|
|
60 |
</TwitterShareButton>
|
|
|
61 |
<TelegramShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
62 |
<TelegramIcon size={32} round />
|
|
|
63 |
</TelegramShareButton>
|
|
|
64 |
<WhatsappShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
65 |
<WhatsappIcon size={32} round />
|
|
|
66 |
</WhatsappShareButton>
|
|
|
67 |
<PinterestShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
68 |
<PinterestIcon size={32} round />
|
|
|
69 |
</PinterestShareButton>
|
|
|
70 |
<RedditShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
71 |
<RedditIcon size={32} round />
|
|
|
72 |
</RedditShareButton>
|
|
|
73 |
<TumblrShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
74 |
<TumblrIcon size={32} round />
|
|
|
75 |
</TumblrShareButton>
|
|
|
76 |
<WorkplaceShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
77 |
<WorkplaceIcon size={32} round />
|
|
|
78 |
</WorkplaceShareButton>
|
|
|
79 |
<EmailShareButton url={`${window.location.hostname}${post.share_external_url}`}>
|
|
|
80 |
<EmailIcon size={32} round />
|
|
|
81 |
</EmailShareButton>
|
|
|
82 |
</div>
|
|
|
83 |
}
|
1 |
www |
84 |
</div>
|
|
|
85 |
</div>
|
3361 |
stevensc |
86 |
</div >
|
1 |
www |
87 |
)
|
|
|
88 |
}
|