Rev 1 | Rev 3363 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */
import React, { useState } from 'react'
import parse from "html-react-parser";
import moment from 'moment'
import { BiDotsVerticalRounded } from 'react-icons/bi'
import { EmailIcon, EmailShareButton, FacebookIcon, FacebookMessengerIcon, FacebookMessengerShareButton, FacebookShareButton, PinterestIcon, PinterestShareButton, RedditIcon, RedditShareButton, TelegramIcon, TelegramShareButton, TumblrIcon, TumblrShareButton, TwitterIcon, TwitterShareButton, WhatsappIcon, WhatsappShareButton, WorkplaceIcon, WorkplaceShareButton } from 'react-share';
import { useRef } from 'react';
export default function PostView({ post = {} }) {
const baseUrl = `/storage/type/post/code/${post.uuid}/filename/`
const shareContainer = useRef(null)
const [shareOptions, setShareOptions] = useState(false)
return (
<div className='container'>
<div
className='row p-2 m-2'
style={{ backgroundColor: 'white' }}
>
<div className='col-md-6 col-sm-12 col-12'>
<div className="card">
<img className="card-img-top" src={baseUrl + post.image} alt={post.title} />
</div>
</div>
<div className='col-md-6 col-sm-12 col-12 d-flex align-items-center position-relative'>
<div className="card border-0">
<div className="card-body">
<h1 className="card-title font-weight-bold border-bottom">{post.title}</h1>
<p> {moment(post.date).format('DD-MM-YYYY')} </p>
<p className="card-text">
{parse(post.description)}
</p>
{
!!post.file &&
<a href={baseUrl + post.file} target='_blank' className="btn btn-primary mt-2" rel="noreferrer">
<i className="fa fa-file" /> Ver adjunto
</a>
}
</div>
</div>
<button
className="btn p-0"
onClick={() => setShareOptions(!shareOptions)}
style={{ right: '0', top: '0' }}
>
<BiDotsVerticalRounded />
</button>
{
shareOptions &&
<div className="ext_share" ref={shareContainer}>
<FacebookShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<FacebookIcon size={32} round />
</FacebookShareButton>
<FacebookMessengerShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<FacebookMessengerIcon size={32} round />
</FacebookMessengerShareButton>
<TwitterShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<TwitterIcon size={32} round />
</TwitterShareButton>
<TelegramShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<TelegramIcon size={32} round />
</TelegramShareButton>
<WhatsappShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<WhatsappIcon size={32} round />
</WhatsappShareButton>
<PinterestShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<PinterestIcon size={32} round />
</PinterestShareButton>
<RedditShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<RedditIcon size={32} round />
</RedditShareButton>
<TumblrShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<TumblrIcon size={32} round />
</TumblrShareButton>
<WorkplaceShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<WorkplaceIcon size={32} round />
</WorkplaceShareButton>
<EmailShareButton url={`${window.location.hostname}${post.share_external_url}`}>
<EmailIcon size={32} round />
</EmailShareButton>
</div>
}
</div>
</div>
</div >
)
}