2023-07-22 13:36:33 +04:00
|
|
|
'use client'
|
|
|
|
|
|
2020-12-11 01:41:37 +01:00
|
|
|
import {useState} from 'react'
|
2023-07-22 13:36:33 +04:00
|
|
|
import {useRouter} from 'next/navigation'
|
2020-12-11 01:41:37 +01:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
2023-07-22 13:36:33 +04:00
|
|
|
import CardActionArea from '@mui/material/CardActionArea'
|
|
|
|
|
import Grid from '@mui/material/Unstable_Grid2'
|
|
|
|
|
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 ExpandMoreIcon from '@mui/icons-material/ExpandMore'
|
|
|
|
|
import {styled} from '@mui/material/styles'
|
2020-12-11 01:41:37 +01:00
|
|
|
|
|
|
|
|
import MizikLis from './mizik-lis'
|
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
|
|
|
const [expanded, setExpanded] = useState(false)
|
|
|
|
|
|
|
|
|
|
const handleExpandClick = () => {
|
|
|
|
|
setExpanded(!expanded)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-20 00:26:22 +04:00
|
|
|
<Grid item xs={12} sm={6} md={4}>
|
|
|
|
|
<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}
|
2022-05-20 02:18:16 +04:00
|
|
|
image={`${photo?.data?.attributes?.url ? `${IMAGE_URL}${photo?.data?.attributes?.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'>
|
2023-03-19 21:35:33 +04:00
|
|
|
{`${paroles.data.length === 0 ? 'Aucune parole pour le moment' : `${paroles.data.length} ${paroles.data.length > 1 ? 'paroles' : 'parole'}`}`}
|
2022-01-19 07:06:26 +04:00
|
|
|
</Typography>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
|
2023-03-19 21:35:33 +04:00
|
|
|
{paroles.data.length > 0 && (
|
|
|
|
|
<CardActions disableSpacing>
|
|
|
|
|
<IconButton
|
|
|
|
|
className={clsx(classes.expand, {
|
|
|
|
|
[classes.expandOpen]: expanded
|
|
|
|
|
})}
|
|
|
|
|
aria-expanded={expanded}
|
|
|
|
|
aria-label='show more'
|
|
|
|
|
size='large'
|
|
|
|
|
onClick={handleExpandClick}
|
|
|
|
|
>
|
|
|
|
|
<ExpandMoreIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</CardActions>
|
|
|
|
|
)}
|
2022-01-19 07:06:26 +04:00
|
|
|
<Collapse unmountOnExit in={expanded} timeout='auto'>
|
|
|
|
|
<CardContent>
|
2022-05-20 02:18:16 +04:00
|
|
|
<MizikLis paroles={paroles.data} />
|
2022-01-19 07:06:26 +04:00
|
|
|
</CardContent>
|
|
|
|
|
</Collapse>
|
|
|
|
|
</Card>
|
2022-01-20 00:26:22 +04:00
|
|
|
{esByografiOuve && (
|
|
|
|
|
<AwtisBiyografi
|
|
|
|
|
alias={alias}
|
2022-05-20 02:18:16 +04:00
|
|
|
paroles={paroles.data}
|
|
|
|
|
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
|
|
|
}
|