Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2384 | Rev 2806 | 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 { Container, Grid } from '@mui/material'

import { usePosts } from '@hooks'

import PostCard from '@app/components/post/PostCard'
import HomeNews from '@app/components/widgets/default/HomeNews'

const PostViewPage = () => {
  const { uuid } = useParams()
  const {
    post,
    addComment,
    updateTotalShare,
    updateMyReaction,
    updateReactions
  } = usePosts(`/post/${uuid}`)

  return (
    <Container as='main' className='px-0'>
      <Grid container spacing={2}>
        <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>
    </Container>
  )
}

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