Rev 3274 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react';
import { useParams } from 'react-router-dom';
import { Grid } from '@mui/material';
import { usePosts } from '@hooks';
import PostCard from '@components/post/PostCard';
import HomeNews from '@components/widgets/default/HomeNews';
const PostViewPage = () => {
const { uuid } = useParams();
const { post, addComment, updateTotalShare, updateMyReaction, updateReactions } = usePosts(
`/post/${uuid}`
);
return (
<Grid container spacing={1}>
<Grid size={{ xs: 12, md: 8 }}>
<PostCard
post={post}
addComment={addComment}
updateTotalShare={updateTotalShare}
updateMyReaction={updateMyReaction}
updateReactions={updateReactions}
/>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<HomeNews currentPost={post.uuid} />
</Grid>
</Grid>
);
};
export const renderContent = ({ type, file }) => {
switch (type) {
case 'video': {
return <video src={file} controls preload='none' controlsList='nodownload' />;
}
case 'image': {
return <img src={file} />;
}
case 'document': {
return (
<a href={file} download>
<img className='pdf' src='/images/extension/pdf.png' alt='pdf' />
</a>
);
}
case 'audio': {
return (
<audio controls>
<source src={file} />
</audio>
);
}
default: {
return (
<a href={file} download>
<img className='pdf' src='/images/extension/pdf.png' alt='pdf' />
</a>
);
}
}
};
export default PostViewPage;