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

84 lines
2.2 KiB
JavaScript
Raw Normal View History

2021-09-21 21:28:04 +02:00
import {useRef, useEffect} from 'react'
2020-12-11 01:50:24 +01:00
import PropTypes from 'prop-types'
import {
Button,
Box,
Typography,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle
2022-01-19 07:06:26 +04:00
} from '@mui/material'
2020-12-11 01:50:24 +01:00
import MizikBadjMeni from './mizik-badj-meni'
2022-05-20 02:18:16 +04:00
export default function AwtisBiyografi({alias, paroles, biographie, esByografiOuve, meteEsByografiOuve}) {
2020-12-11 01:50:24 +01:00
const handleClose = () => {
2020-12-18 22:13:52 +01:00
meteEsByografiOuve(false)
2020-12-11 01:50:24 +01:00
}
2021-09-21 21:28:04 +02:00
const descriptionElementRef = useRef(null)
useEffect(() => {
2020-12-18 22:13:52 +01:00
if (esByografiOuve) {
2020-12-11 01:50:24 +01:00
const {current: descriptionElement} = descriptionElementRef
if (descriptionElement !== null) {
descriptionElement.focus()
}
}
2020-12-18 22:13:52 +01:00
}, [esByografiOuve])
2020-12-11 01:50:24 +01:00
return (
<div>
<Dialog
scroll='paper'
2020-12-18 22:13:52 +01:00
open={esByografiOuve}
2020-12-11 01:50:24 +01:00
aria-labelledby='scroll-dialog-title'
aria-describedby='scroll-dialog-description'
onClose={handleClose}
>
<Box display='flex' justifyContent='center' alignItems='center'>
<DialogTitle id='scroll-dialog-title' align='center'>{alias}</DialogTitle>
2022-05-20 02:18:16 +04:00
<MizikBadjMeni paroles={paroles} />
2020-12-11 01:50:24 +01:00
</Box>
<DialogContent dividers>
<DialogContentText
ref={descriptionElementRef}
align='justify'
id='scroll-dialog-description'
tabIndex={-1}
>
2022-05-20 02:18:16 +04:00
{biographie ? (
2020-12-11 01:50:24 +01:00
<Typography component='span'>
2022-05-20 02:18:16 +04:00
{biographie}
2020-12-11 01:50:24 +01:00
</Typography>
) : (
<Typography component='span'>
Pas de biobraphie disponible
</Typography>
)}
</DialogContentText>
</DialogContent>
<DialogActions style={{margin: 'auto'}}>
2020-12-12 03:28:51 +01:00
<Button variant='outlined' color='primary' onClick={handleClose}>
2022-05-20 02:18:16 +04:00
Fermer
2020-12-11 01:50:24 +01:00
</Button>
</DialogActions>
</Dialog>
</div>
)
}
2020-12-18 19:37:28 +01:00
AwtisBiyografi.propTypes = {
2020-12-11 01:50:24 +01:00
alias: PropTypes.string.isRequired,
2022-05-20 02:18:16 +04:00
paroles: PropTypes.array.isRequired,
biographie: PropTypes.string,
2020-12-18 22:13:52 +01:00
esByografiOuve: PropTypes.bool.isRequired,
meteEsByografiOuve: PropTypes.func.isRequired
2020-12-11 01:50:24 +01:00
}
2020-12-18 19:37:28 +01:00
AwtisBiyografi.defaultProps = {
2022-05-20 02:18:16 +04:00
biographie: null
2020-12-11 01:50:24 +01:00
}