Files
pawol.nu/components/awtis/awtis-kat.js
T

99 lines
2.7 KiB
JavaScript
Raw Normal View History

'use client'
2020-12-11 01:41:37 +01:00
import {useState} from 'react'
import {useRouter} from 'next/navigation'
2020-12-11 01:41:37 +01:00
import PropTypes from 'prop-types'
import CardActionArea from '@mui/material/CardActionArea'
import Grid from '@mui/material/Grid'
import Card from '@mui/material/Card'
import CardMedia from '@mui/material/CardMedia'
import CardContent from '@mui/material/CardContent'
import Typography from '@mui/material/Typography'
2020-12-11 01:41:37 +01:00
2022-01-19 07:06:26 +04:00
import {styled} from '@mui/material/styles'
2020-12-11 01:41:37 +01:00
2020-12-18 19:37:28 +01:00
import AwtisBiyografi from './awtis-biyografi'
2020-12-11 01:41:37 +01:00
2022-01-19 06:35:04 +04:00
const PREFIX = 'awtis-kat'
2022-05-11 03:12:49 +04:00
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3001'
2022-05-20 02:18:16 +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`,
expand: `${PREFIX}-expand`,
expandOpen: `${PREFIX}-expandOpen`
}
2022-01-20 00:26:22 +04:00
const Kat = styled('div')((
2022-01-19 06:35:04 +04:00
{
theme
}
) => ({
[`& .${classes.media}`]: {
2020-12-11 01:41:37 +01:00
height: 240,
objectFit: 'contain'
},
2022-01-19 06:35:04 +04:00
[`& .${classes.expand}`]: {
2020-12-11 01:41:37 +01:00
transform: 'rotate(0deg)',
marginLeft: 'auto',
transition: theme.transitions.create('transform', {
duration: theme.transitions.duration.shortest
})
},
2022-01-19 06:35:04 +04:00
[`& .${classes.expandOpen}`]: {
2020-12-11 01:41:37 +01:00
transform: 'rotate(180deg)'
}
}))
2022-05-20 02:18:16 +04:00
const noImageUrl = 'https://place-hold.it/140x140?text=Indisponible'
export default function AwtisKat({artiste}) {
2022-05-11 03:12:49 +04:00
const router = useRouter()
2020-12-18 22:13:52 +01:00
const [esByografiOuve, meteEsByografiOuve] = useState(false)
2020-12-11 01:41:37 +01:00
2022-05-20 02:18:16 +04:00
const {alias, biographie, paroles, photo, slug} = artiste
2022-01-19 06:35:04 +04:00
2020-12-11 01:41:37 +01:00
return (
2024-10-21 10:06:16 +04:00
<Grid size={{xs: 12, sm: 6, md: 4}}>
2022-01-20 00:26:22 +04:00
<Kat>
<Card sx={{maxWidth: 340}}>
2022-05-11 03:12:49 +04:00
<CardActionArea onClick={() => router.push(`${SITE_URL}/awtis/${slug}`)}>
2022-01-19 07:06:26 +04:00
<CardMedia
className={classes.media}
component='img'
alt={alias}
2026-04-21 19:16:11 +04:00
image={`${photo?.url ? `${IMAGE_URL}${photo?.url}` : noImageUrl}`}
2022-01-19 07:06:26 +04:00
title={alias}
/>
<CardContent>
<Typography gutterBottom align='center' variant='h5' component='h2'>
{alias}
</Typography>
<Typography align='center' variant='body2' color='textSecondary' component='h5'>
2026-04-21 19:16:11 +04:00
{`${paroles.length === 0 ? 'Aucune parole pour le moment' : `${paroles.length} ${paroles.length > 1 ? 'paroles' : 'parole'}`}`}
2022-01-19 07:06:26 +04:00
</Typography>
</CardContent>
</CardActionArea>
</Card>
2022-01-20 00:26:22 +04:00
{esByografiOuve && (
<AwtisBiyografi
alias={alias}
2026-04-21 19:16:11 +04:00
paroles={paroles}
2022-05-20 02:18:16 +04:00
biographie={biographie}
2022-01-20 00:26:22 +04:00
esByografiOuve={esByografiOuve}
meteEsByografiOuve={meteEsByografiOuve}
/>
)}
</Kat>
</Grid>
2020-12-11 01:41:37 +01:00
)
}
AwtisKat.propTypes = {
2022-05-20 02:18:16 +04:00
artiste: PropTypes.object.isRequired
2020-12-11 01:41:37 +01:00
}