2024-05-20 14:49:31 +04:00
|
|
|
'use client'
|
|
|
|
|
|
2024-05-18 09:36:44 +04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
import Paper from '@mui/material/Paper'
|
2024-05-20 14:49:31 +04:00
|
|
|
import {styled} from '@mui/material/styles'
|
|
|
|
|
import IconButton from '@mui/material/IconButton'
|
|
|
|
|
import AddCommentIcon from '@mui/icons-material/AddComment'
|
|
|
|
|
import Tooltip, {tooltipClasses} from '@mui/material/Tooltip'
|
2024-05-18 09:36:44 +04:00
|
|
|
import Titre from './titre.js'
|
|
|
|
|
import Article from './article.js'
|
2024-05-20 04:17:45 +04:00
|
|
|
import {formatKonstitisyon} from '@/lib/format.js'
|
2024-05-18 09:36:44 +04:00
|
|
|
|
2024-05-20 14:49:31 +04:00
|
|
|
const LightTooltip = styled(({className, ...props}) => (
|
|
|
|
|
<Tooltip {...props} classes={{popper: className}} />
|
|
|
|
|
))(({theme}) => ({
|
|
|
|
|
[`& .${tooltipClasses.tooltip}`]: {
|
|
|
|
|
backgroundColor: theme.palette.common.white,
|
|
|
|
|
color: 'rgba(0, 0, 0, 0.87)',
|
|
|
|
|
boxShadow: theme.shadows[1],
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
},
|
|
|
|
|
}))
|
|
|
|
|
|
2024-05-20 14:48:52 +04:00
|
|
|
export default function Konstitisyon({session, titres, articles}) {
|
2024-05-18 09:36:44 +04:00
|
|
|
const konstitisyon = formatKonstitisyon(titres, articles)
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box>
|
|
|
|
|
{konstitisyon.map(({titreId, titre, articles}) => (
|
|
|
|
|
<Paper key={titreId} variant='outlined' sx={{p: 1, marginBlock: 2}} p={2} >
|
2024-05-20 14:48:52 +04:00
|
|
|
<Titre session={session} titreId={titreId} titre={titre} />
|
2024-05-18 09:36:44 +04:00
|
|
|
{articles.map(({id, numero, contenu}) => (
|
2024-05-20 14:48:52 +04:00
|
|
|
<Article key={id} session={session} articleId={id} numero={numero} contenu={contenu} />
|
2024-05-18 09:36:44 +04:00
|
|
|
))}
|
2024-05-20 14:49:31 +04:00
|
|
|
{session && (
|
|
|
|
|
<Box sx={{textAlign: 'right'}}>
|
|
|
|
|
<IconButton size='large' aria-label='commenter'>
|
|
|
|
|
<LightTooltip title='Commenter'>
|
|
|
|
|
<AddCommentIcon color='warning' fontSize='inherit' />
|
|
|
|
|
</LightTooltip>
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2024-05-18 09:36:44 +04:00
|
|
|
</Paper>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Konstitisyon.propTypes = {
|
2024-05-20 14:48:52 +04:00
|
|
|
session: PropTypes.object,
|
2024-05-18 09:36:44 +04:00
|
|
|
titres: PropTypes.object.isRequired,
|
|
|
|
|
articles: PropTypes.object.isRequired
|
|
|
|
|
}
|