Rev 2385 | Rev 2388 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react'import { useSelector } from 'react-redux'import { Container, Grid } from '@mui/material'import parse from 'html-react-parser'import useFetch from '@app/hooks/useFetch'import Widget from '@app/components/UI/Widget'import SurveyForm from '@app/components/survey-form/SurveyForm'import AuthNavbar from '@app/components/UI/auth-navbar'import { useParams } from 'react-router-dom'function ShorterPostPage() {const { isAuth } = useSelector((state) => state.auth)const { id } = useParams()const { data } = useFetch(`/shorter/${id}`, null)const { data: post } = useFetch(data)const { shared_image, shared_title, shared_description } = postreturn (<>{!isAuth ? <AuthNavbar /> : null}<Container><Gridcontainersx={{display: 'flex',justifyContent: 'center',alignItems: 'center'}}><Grid item xs={12} md={8}><Widget><Widget.Header avatar={shared_image} title={shared_title} /><Widget.Body><FeedContenttype='description'content={{ owner_description: shared_description ?? '' }}/></Widget.Body></Widget></Grid></Grid></Container></>)}const FeedContent = ({ type, content }) => {const renderContent = ({owner_description,owner_file_image_preview,owner_file_video,owner_file_image,shared_name,shared_image,shared_time_elapse,feed_vote_url}) => {switch (type) {case 'fast-survey': {const answers = []const votes = []for (let i = 1; i < 6; i++) {answers.push(owner_description[`answer${i}`])votes.push(owner_description[`votes${i}`])}return (<SurveyFormactive={owner_description.active}question={owner_description.question}answers={answers}votes={votes}time={owner_description.time_remaining}voteUrl={feed_vote_url}resultType={owner_description.result_type}/>)}case 'video': {return (<>{parse(owner_description ?? '')}<video controls poster={owner_file_image_preview}><source src={owner_file_video} /></video></>)}case 'image': {return (<>{parse(owner_description ?? '')}<img src={owner_file_image} loading='lazy' /></>)}case 'document': {return (<>{parse(owner_description ?? '')}<a href={document} target='_blank' rel='noreferrer'><img className='pdf' src='/images/extension/pdf.png' alt='pdf' /></a></>)}case 'shared': {return (<>{parse(owner_description ?? '')}<Widget><Widget.Headeravatar={shared_image}title={shared_name}subheader={shared_time_elapse}/><Widget.Body>{renderContent({owner_description,owner_file_image_preview,owner_file_video,owner_file_image,shared_name,shared_image,shared_time_elapse,feed_vote_url})}</Widget.Body></Widget></>)}default: {return parse(owner_description)}}}return <>{renderContent(content)}</>}export default ShorterPostPage