refactor: Improve edit components

This commit is contained in:
2024-07-06 16:41:34 +02:00
parent 79cc1c0dd8
commit 3ec2944189
4 changed files with 22 additions and 18 deletions
+28
View File
@@ -0,0 +1,28 @@
import PropTypes from 'prop-types'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import Edit from './index.js'
export default function Article({session, articleId, numero, contenu}) {
const formattedContent = contenu.replaceAll('\n', '<br />')
return (
<Box textAlign='justify' p={0.5}>
<Box sx={{display: 'flex', alignItems: 'center'}}>
<Typography marginBlock={1} fontWeight='bold'>{!numero || numero === 0 ? 'Article ...' : `Article ${numero}`}</Typography>
{session && (
<Edit session={session} id={articleId} contenu={contenu} collection='articles' />
)}
</Box>
<Typography dangerouslySetInnerHTML={{__html: formattedContent}} />
</Box>
)
}
Article.propTypes = {
session: PropTypes.object,
articleId: PropTypes.string.isRequired,
numero: PropTypes.number,
contenu: PropTypes.string.isRequired
}