2023-07-22 13:36:33 +04:00
|
|
|
'use client'
|
|
|
|
|
|
2020-12-17 09:05:40 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2023-07-22 13:36:33 +04:00
|
|
|
import {useRouter} from 'next/navigation'
|
2024-04-14 07:07:49 +04:00
|
|
|
import Image from 'next/image'
|
2020-12-17 09:05:40 +01:00
|
|
|
import {format} from 'date-fns'
|
|
|
|
|
import {fr} from 'date-fns/locale'
|
2023-07-22 13:36:33 +04:00
|
|
|
import Card from '@mui/material/Card'
|
|
|
|
|
|
|
|
|
|
import CardActionArea from '@mui/material/CardActionArea'
|
|
|
|
|
import CardContent from '@mui/material/CardContent'
|
|
|
|
|
import CardMedia from '@mui/material/CardMedia'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Box from '@mui/material/Box'
|
2026-04-21 19:31:26 +04:00
|
|
|
import Grid from '@mui/material/Grid'
|
2022-01-19 07:06:26 +04:00
|
|
|
import ExplicitIcon from '@mui/icons-material/Explicit'
|
|
|
|
|
import {styled} from '@mui/material/styles'
|
2020-12-17 09:05:40 +01:00
|
|
|
|
2022-05-22 00:17:28 +04:00
|
|
|
import {getAlias} from '../../lib/utils/format'
|
|
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const PREFIX = 'teks-kat'
|
2022-05-17 09:01:31 +04:00
|
|
|
const IMAGE_URL = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337'
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
|
root: `${PREFIX}-root`,
|
|
|
|
|
media: `${PREFIX}-media`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const StyledGrid = styled(Grid)({
|
|
|
|
|
[`& .${classes.root}`]: {
|
2020-12-17 09:05:40 +01:00
|
|
|
maxWidth: 345
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
[`& .${classes.media}`]: {
|
2020-12-17 09:05:40 +01:00
|
|
|
height: 240,
|
|
|
|
|
objectFit: 'contain'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
const noImageUrl = 'https://place-hold.it/140x140?text=Indisponible'
|
2022-05-17 09:01:31 +04:00
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
export default function TeksKat({parole}) {
|
2020-12-17 09:05:40 +01:00
|
|
|
const router = useRouter()
|
2026-04-21 19:16:11 +04:00
|
|
|
const {titre, artistes, annee, couverture, publishedAt, slug} = parole
|
2022-05-17 09:01:31 +04:00
|
|
|
|
|
|
|
|
const datPiblikasyon = format(new Date(publishedAt), 'P', {locale: fr})
|
2026-04-21 19:16:11 +04:00
|
|
|
const aliases = getAlias(artistes, parole.prioriteArtistes)
|
2020-12-17 09:05:40 +01:00
|
|
|
|
|
|
|
|
const handleClick = slug => {
|
2023-07-22 13:54:58 +04:00
|
|
|
router.push(`/paroles/${slug}`)?.then(() => window.scrollTo(0, 0))
|
2020-12-17 09:05:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-10-21 10:06:16 +04:00
|
|
|
<StyledGrid size={{xs: 12, sm: 6, md: 4}}>
|
2020-12-17 09:05:40 +01:00
|
|
|
<Card className={classes.root}>
|
|
|
|
|
<CardActionArea onClick={() => handleClick(slug)}>
|
|
|
|
|
<CardMedia
|
|
|
|
|
className={classes.media}
|
|
|
|
|
component='img'
|
2022-05-17 09:01:31 +04:00
|
|
|
alt={titre}
|
2026-04-21 19:16:11 +04:00
|
|
|
image={couverture?.url ? `${IMAGE_URL}${couverture.url}` : noImageUrl}
|
2022-05-17 09:01:31 +04:00
|
|
|
title={titre}
|
2020-12-17 09:05:40 +01:00
|
|
|
/>
|
|
|
|
|
<CardContent>
|
2022-10-27 19:36:52 +04:00
|
|
|
<Box sx={{display: 'flex', alignItems: 'center'}}>
|
|
|
|
|
<Typography display='inline' style={{marginRight: 5}} variant='h6' component='h2'>
|
|
|
|
|
{titre}
|
|
|
|
|
</Typography>
|
2026-04-21 19:16:11 +04:00
|
|
|
{parole.creativeCommons && (
|
2024-04-14 07:07:49 +04:00
|
|
|
<Box marginInline={1}>
|
|
|
|
|
<Image
|
|
|
|
|
width={24}
|
|
|
|
|
height={24}
|
|
|
|
|
title='Creative Commons'
|
|
|
|
|
alt='ccheart_red'
|
|
|
|
|
src='/images/cc/icons/ccheart_red.svg'
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-04-21 19:16:11 +04:00
|
|
|
{parole.explicitLyrics && (
|
2023-07-26 08:06:27 +04:00
|
|
|
<ExplicitIcon style={{marginRight: 5}} color='error' fontSize='small' />
|
2022-10-27 19:36:52 +04:00
|
|
|
)}
|
|
|
|
|
</Box>
|
2023-07-22 13:54:58 +04:00
|
|
|
<Box sx={{textAlign: 'start'}}>
|
|
|
|
|
<Typography variant='body2' color='textSecondary' component='p'>
|
|
|
|
|
{aliases}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography variant='body2' color='textSecondary' component='p'>
|
|
|
|
|
{annee}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{fontStyle: 'italic'}} variant='caption'>
|
2026-04-21 19:16:11 +04:00
|
|
|
{parole.user && (
|
2023-07-22 13:54:58 +04:00
|
|
|
<>
|
2026-04-21 19:16:11 +04:00
|
|
|
(<i>parole soumise par {parole.user.username}</i>)
|
2023-07-22 13:54:58 +04:00
|
|
|
</>
|
|
|
|
|
)}
|
2026-04-21 19:16:11 +04:00
|
|
|
{parole.userAdmin && !parole.user && (
|
2023-07-22 13:54:58 +04:00
|
|
|
<>
|
2026-04-21 19:16:11 +04:00
|
|
|
(<i>parole soumise par {parole.userAdmin}</i>)
|
2023-07-22 13:54:58 +04:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography align='center' style={{marginTop: '0.5em'}} variant='body1' color='textSecondary' component='p'>
|
|
|
|
|
Publiée le : {datPiblikasyon}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2020-12-17 09:05:40 +01:00
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
</Card>
|
2022-01-19 06:35:04 +04:00
|
|
|
</StyledGrid>
|
2020-12-17 09:05:40 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksKat.propTypes = {
|
2022-05-20 02:15:56 +04:00
|
|
|
parole: PropTypes.object.isRequired
|
2020-12-17 09:05:40 +01:00
|
|
|
}
|