2020-12-17 09:05:40 +01:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import {useRouter} from 'next/router'
|
|
|
|
|
import {format} from 'date-fns'
|
|
|
|
|
import {fr} from 'date-fns/locale'
|
|
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardActionArea,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardMedia,
|
|
|
|
|
Typography,
|
|
|
|
|
Grid
|
|
|
|
|
} from '@material-ui/core'
|
2021-05-28 17:03:27 +02:00
|
|
|
import ExplicitIcon from '@material-ui/icons/Explicit'
|
2020-12-17 09:05:40 +01:00
|
|
|
import {makeStyles} from '@material-ui/core/styles'
|
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
|
|
|
root: {
|
|
|
|
|
maxWidth: 345
|
|
|
|
|
},
|
|
|
|
|
media: {
|
|
|
|
|
height: 240,
|
|
|
|
|
objectFit: 'contain'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default function TeksKat({teks}) {
|
|
|
|
|
const classes = useStyles()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const noImageUrl = 'https://place-hold.it/140x140?text=Pa%20ni%20imaj'
|
2020-12-18 22:08:34 +01:00
|
|
|
const {tit, awtis, lanne, kouveti, published_at, slug} = teks
|
2020-12-20 17:52:42 +01:00
|
|
|
const datPiblikasyon = format(new Date(published_at), 'P', {locale: fr})
|
2020-12-17 09:05:40 +01:00
|
|
|
|
|
|
|
|
const handleClick = slug => {
|
2020-12-17 23:19:21 +01:00
|
|
|
router.push(`/teks/${slug}#${slug}`).then(() => window.scrollTo(0, 0))
|
2020-12-17 09:05:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Grid item sm={12} md={6} lg={4}>
|
|
|
|
|
<Card className={classes.root}>
|
|
|
|
|
<CardActionArea onClick={() => handleClick(slug)}>
|
|
|
|
|
<CardMedia
|
|
|
|
|
className={classes.media}
|
|
|
|
|
component='img'
|
2020-12-18 22:08:34 +01:00
|
|
|
alt={tit}
|
|
|
|
|
image={kouveti ? `${process.env.NEXT_PUBLIC_API_URL}${kouveti.url}` : noImageUrl}
|
|
|
|
|
title={tit}
|
2020-12-17 09:05:40 +01:00
|
|
|
/>
|
|
|
|
|
<CardContent>
|
2021-05-26 02:49:06 +02:00
|
|
|
<Typography display='inline' style={{marginRight: 5}} variant='h6' component='h2'>
|
2020-12-18 22:08:34 +01:00
|
|
|
{tit}
|
2020-12-17 09:05:40 +01:00
|
|
|
</Typography>
|
2021-05-28 17:03:27 +02:00
|
|
|
{teks.eksplisit && (
|
|
|
|
|
<ExplicitIcon style={{marginRight: 5}} color='secondary' fontSize='small' />
|
|
|
|
|
)}
|
2021-05-26 02:49:06 +02:00
|
|
|
<Typography variant='caption'>
|
|
|
|
|
{teks.user && (
|
|
|
|
|
<>
|
|
|
|
|
(<i>retranscrit par {teks.user.username}</i>)
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Typography>
|
2020-12-17 09:05:40 +01:00
|
|
|
<Typography variant='body2' color='textSecondary' component='p'>
|
2021-03-07 15:11:09 +01:00
|
|
|
{awtis.map(a => a.alias).join(', ')}
|
2020-12-17 09:05:40 +01:00
|
|
|
</Typography>
|
|
|
|
|
<Typography variant='body2' color='textSecondary' component='p'>
|
2020-12-18 22:08:34 +01:00
|
|
|
{lanne}
|
2020-12-17 09:05:40 +01:00
|
|
|
</Typography>
|
|
|
|
|
<Typography align='center' style={{marginTop: '0.5em'}} variant='body1' color='textSecondary' component='p'>
|
|
|
|
|
Piblikasyon : {datPiblikasyon}
|
|
|
|
|
</Typography>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
</Card>
|
|
|
|
|
</Grid>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksKat.propTypes = {
|
|
|
|
|
teks: PropTypes.object.isRequired
|
|
|
|
|
}
|