fix: ferme les votes sur les versions obsolètes dans PDF/Print

This commit is contained in:
2026-01-04 13:06:30 +04:00
parent e101f503d2
commit 2701957af8
5 changed files with 105 additions and 60 deletions
+4 -2
View File
@@ -49,7 +49,7 @@ const renderMarkdownToHtml = async content => {
}
}
export default function PrintButton({versionData, size = 'medium', variant = 'outlined'}) {
export default function PrintButton({versionData, isOutdated = false, size = 'medium', variant = 'outlined'}) {
const [isPrinting, setIsPrinting] = useState(false)
const [snackbar, setSnackbar] = useState({open: false, message: '', severity: 'success'})
@@ -61,7 +61,8 @@ export default function PrintButton({versionData, size = 'medium', variant = 'ou
const authorName = versionData.user_created?.split('-')[0] || 'Système'
const createdAt = new Date(versionData.date_created)
const threeDaysAgo = new Date(Date.now() - (3 * 24 * 60 * 60 * 1000))
const voteStatus = createdAt < threeDaysAgo ? 'fermé' : 'ouvert'
const isExpired = createdAt < threeDaysAgo
const voteStatus = (isExpired || isOutdated) ? 'fermé' : 'ouvert'
const voteColor = voteStatus === 'ouvert' ? '#2e7d32' : '#d32f2f'
// Render markdown content to HTML
@@ -390,6 +391,7 @@ export default function PrintButton({versionData, size = 'medium', variant = 'ou
PrintButton.propTypes = {
versionData: PropTypes.object.isRequired,
isOutdated: PropTypes.bool,
size: PropTypes.oneOf(['small', 'medium', 'large']),
variant: PropTypes.oneOf(['text', 'outlined', 'contained'])
}