Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2885 | Ir a la última revisión | 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 item xs={12} md={8}>
        <PostCard
          post={post}
          addComment={addComment}
          updateTotalShare={updateTotalShare}
          updateMyReaction={updateMyReaction}
          updateReactions={updateReactions}
        />
      </Grid>

      <Grid item 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