2020-12-11 01:41:37 +01:00
|
|
|
import {useState} from 'react'
|
2022-05-11 03:12:49 +04:00
|
|
|
import {useRouter} from 'next/router'
|
2020-12-11 01:41:37 +01:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import clsx from 'clsx'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
CardActionArea,
|
|
|
|
|
Grid,
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardMedia,
|
|
|
|
|
CardActions,
|
|
|
|
|
Collapse,
|
|
|
|
|
IconButton,
|
|
|
|
|
Typography
|
2022-01-19 07:06:26 +04:00
|
|
|
} from '@mui/material'
|
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-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)'
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
export default function AwtisKat({anAwtis}) {
|
2022-05-11 03:12:49 +04:00
|
|
|
const router = useRouter()
|
2020-12-18 22:13:52 +01:00
|
|
|
const [esByografiOuve, meteEsByografiOuve] = useState(false)
|
|
|
|
|
const noImageUrl = 'https://place-hold.it/140x140?text=Pa%20ni%20imaj'
|
2020-12-11 01:41:37 +01:00
|
|
|
|
2022-05-11 03:12:49 +04:00
|
|
|
const {alias, biyografi, teks, foto, slug} = anAwtis
|
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}
|
|
|
|
|
image={`${foto.length > 0 ? `${process.env.NEXT_PUBLIC_API_URL}${foto[0].url}` : noImageUrl}`}
|
|
|
|
|
title={alias}
|
|
|
|
|
/>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<Typography gutterBottom align='center' variant='h5' component='h2'>
|
|
|
|
|
{alias}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography align='center' variant='body2' color='textSecondary' component='h5'>
|
|
|
|
|
{anAwtis.teks.length} tèks
|
|
|
|
|
</Typography>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
|
|
|
|
|
<CardActions disableSpacing>
|
|
|
|
|
<IconButton
|
|
|
|
|
className={clsx(classes.expand, {
|
|
|
|
|
[classes.expandOpen]: expanded
|
|
|
|
|
})}
|
|
|
|
|
aria-expanded={expanded}
|
|
|
|
|
aria-label='show more'
|
|
|
|
|
size='large'
|
|
|
|
|
onClick={handleExpandClick}
|
|
|
|
|
>
|
|
|
|
|
<ExpandMoreIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</CardActions>
|
|
|
|
|
<Collapse unmountOnExit in={expanded} timeout='auto'>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<MizikLis teks={teks} />
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Collapse>
|
|
|
|
|
</Card>
|
2022-01-20 00:26:22 +04:00
|
|
|
{esByografiOuve && (
|
|
|
|
|
<AwtisBiyografi
|
|
|
|
|
alias={alias}
|
|
|
|
|
teks={teks}
|
|
|
|
|
biyografi={biyografi}
|
|
|
|
|
esByografiOuve={esByografiOuve}
|
|
|
|
|
meteEsByografiOuve={meteEsByografiOuve}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Kat>
|
|
|
|
|
</Grid>
|
2020-12-11 01:41:37 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AwtisKat.propTypes = {
|
|
|
|
|
anAwtis: PropTypes.object.isRequired
|
|
|
|
|
}
|