2023-07-22 13:36:33 +04:00
|
|
|
'use client'
|
|
|
|
|
|
2022-05-11 03:08:35 +04:00
|
|
|
import {useState} from 'react'
|
2023-07-22 13:36:33 +04:00
|
|
|
import Link from 'next/link'
|
2022-05-11 03:08:35 +04:00
|
|
|
import PropTypes from 'prop-types'
|
2023-07-22 13:36:33 +04:00
|
|
|
import Accordion from '@mui/material/Accordion'
|
|
|
|
|
import AccordionDetails from '@mui/material/AccordionDetails'
|
|
|
|
|
import AccordionSummary from '@mui/material/AccordionSummary'
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
import Button from '@mui/material/Button'
|
|
|
|
|
import CardActionArea from '@mui/material/CardActionArea'
|
|
|
|
|
import Chip from '@mui/material/Chip'
|
|
|
|
|
import Container from '@mui/material/Container'
|
|
|
|
|
import Grid from '@mui/material/Unstable_Grid2'
|
|
|
|
|
import Paper from '@mui/material/Paper'
|
2022-05-11 03:08:35 +04:00
|
|
|
import Card from '@mui/material/Card'
|
|
|
|
|
import CardContent from '@mui/material/CardContent'
|
|
|
|
|
import Avatar from '@mui/material/Avatar'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import {green} from '@mui/material/colors'
|
|
|
|
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
|
|
|
|
|
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
|
|
|
|
|
|
|
|
|
|
import AwtisBiyografi from './awtis-biyografi'
|
|
|
|
|
import MizikLis from './mizik-lis'
|
|
|
|
|
|
2022-05-20 02:18:16 +04:00
|
|
|
const IMAGE_URL = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337'
|
|
|
|
|
const noImageUrl = 'https://place-hold.it/140x140?text=Indisponible'
|
2022-05-11 03:08:35 +04:00
|
|
|
|
2022-05-20 02:18:16 +04:00
|
|
|
const sortTeks = paroles => paroles.sort((a, b) => b.id - a.id)
|
2022-05-11 03:08:35 +04:00
|
|
|
|
|
|
|
|
export default function AwtisDetay({anAwtis}) {
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const [esByografiOuve, meteEsByografiOuve] = useState(false)
|
2022-05-20 02:18:16 +04:00
|
|
|
const {alias, biographie, paroles, photo} = anAwtis
|
|
|
|
|
const sortedTeks = sortTeks(paroles.data)
|
|
|
|
|
const gwanBiyo = biographie && biographie.length > 100
|
2022-05-11 03:08:35 +04:00
|
|
|
|
2022-05-20 02:18:16 +04:00
|
|
|
const biyo = gwanBiyo ? `${biographie.slice(0, 100)}...` : biographie
|
2022-05-11 03:08:35 +04:00
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
meteEsByografiOuve(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleBack = () => {
|
|
|
|
|
const href = '/awtis?paj&paj=1'
|
|
|
|
|
const as = '/awtis/paj/1'
|
|
|
|
|
router.push(href, as)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container>
|
|
|
|
|
<Box sx={{marginBlock: 2}}>
|
|
|
|
|
<Typography textAlign='center' variant='h6' component='h1'>
|
|
|
|
|
{alias}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2022-05-11 10:59:18 +04:00
|
|
|
<Box sx={{justifyContent: 'center', display: 'flex', marginBottom: 2}}>
|
2022-05-11 03:08:35 +04:00
|
|
|
<Avatar
|
2022-05-20 02:18:16 +04:00
|
|
|
src={`${photo?.data?.attributes?.url ? `${IMAGE_URL}${photo?.data?.attributes?.url}` : noImageUrl}`}
|
2022-05-11 03:08:35 +04:00
|
|
|
alt={`Photo ${alias}`}
|
|
|
|
|
sx={{width: 200, height: 200, border: `2px solid ${green[500]}`}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2022-05-11 10:59:18 +04:00
|
|
|
<Grid container direction='column' justifyContent='center' alignItems='center' spacing={3}>
|
2022-05-11 03:08:35 +04:00
|
|
|
{biyo && (
|
|
|
|
|
<Grid item xs={12} md={6}>
|
|
|
|
|
<Card sx={{minWidth: 300}}>
|
|
|
|
|
<CardActionArea onClick={handleClick}>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<Typography gutterBottom variant='body1' component='h2'>
|
|
|
|
|
<strong>Biographie</strong>
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography textAlign='justify' variant='subtitle1' component='h3'>
|
|
|
|
|
{biyo}
|
|
|
|
|
</Typography>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
</Card>
|
|
|
|
|
</Grid>
|
|
|
|
|
)}
|
|
|
|
|
<Grid item xs={12} md={6}>
|
2022-05-11 10:59:18 +04:00
|
|
|
<Box marginBottom={3}>
|
2022-05-20 02:18:16 +04:00
|
|
|
{paroles.data.length > 1 ? (
|
2022-05-11 03:08:35 +04:00
|
|
|
<Accordion>
|
|
|
|
|
<AccordionSummary
|
|
|
|
|
expandIcon={<ExpandMoreIcon />}
|
|
|
|
|
aria-controls='panel-teks-content'
|
|
|
|
|
id='panel-teks-header'
|
|
|
|
|
>
|
2022-05-23 18:34:55 +04:00
|
|
|
<Typography marginRight={2} textAlign='center' variant='body1' component='h2'><strong>Liste des paroles</strong></Typography>
|
2022-05-20 02:18:16 +04:00
|
|
|
<Chip color='primary' label={paroles.data.length} size='small' variant='contained' />
|
2022-05-11 03:08:35 +04:00
|
|
|
</AccordionSummary>
|
|
|
|
|
<AccordionDetails>
|
2022-05-20 04:05:34 +04:00
|
|
|
<MizikLis paroles={sortedTeks} />
|
2022-05-11 03:08:35 +04:00
|
|
|
</AccordionDetails>
|
|
|
|
|
</Accordion>
|
|
|
|
|
) : (
|
2023-03-19 21:35:33 +04:00
|
|
|
paroles.data.length === 0 ? (
|
|
|
|
|
<Typography gutterBottom textAlign='center' variant='body1' component='h2'><strong>Aucune parole pour le moment</strong></Typography>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<Typography gutterBottom textAlign='center' variant='body1' component='h2'><strong>Parole</strong></Typography>
|
|
|
|
|
<Paper>
|
|
|
|
|
<MizikLis paroles={paroles.data} />
|
|
|
|
|
</Paper>
|
|
|
|
|
</>
|
|
|
|
|
)
|
2022-05-11 03:08:35 +04:00
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
2022-05-11 10:59:18 +04:00
|
|
|
<Box sx={{textAlign: 'center', marginBottom: 2}} >
|
|
|
|
|
<Button variant='outlined' startIcon={<KeyboardBackspaceIcon />} onClick={handleBack}>
|
|
|
|
|
Retour aux artistes
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
2022-05-11 03:08:35 +04:00
|
|
|
{esByografiOuve && (
|
|
|
|
|
<AwtisBiyografi
|
|
|
|
|
alias={alias}
|
2022-05-20 02:18:16 +04:00
|
|
|
paroles={paroles.data}
|
|
|
|
|
biographie={biographie}
|
2022-05-11 03:08:35 +04:00
|
|
|
esByografiOuve={esByografiOuve}
|
|
|
|
|
meteEsByografiOuve={meteEsByografiOuve}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Container>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AwtisDetay.propTypes = {
|
|
|
|
|
anAwtis: PropTypes.object.isRequired
|
|
|
|
|
}
|