feat: récupère le total des votes
This commit is contained in:
@@ -49,7 +49,7 @@ const renderMarkdownToHtml = async content => {
|
||||
}
|
||||
}
|
||||
|
||||
export default function PrintButton({versionData, isOutdated = false, size = 'medium', variant = 'outlined'}) {
|
||||
export default function PrintButton({versionData, isOutdated = false, voteCounts = null, size = 'medium', variant = 'outlined'}) {
|
||||
const [isPrinting, setIsPrinting] = useState(false)
|
||||
const [snackbar, setSnackbar] = useState({open: false, message: '', severity: 'success'})
|
||||
|
||||
@@ -65,6 +65,11 @@ export default function PrintButton({versionData, isOutdated = false, size = 'me
|
||||
const voteStatus = (isExpired || isOutdated) ? 'fermé' : 'ouvert'
|
||||
const voteColor = voteStatus === 'ouvert' ? '#2e7d32' : '#d32f2f'
|
||||
|
||||
// Vote counts display
|
||||
const voteTotal = voteCounts ? voteCounts.total : 0
|
||||
const voteTotalColor = voteTotal > 0 ? '#2e7d32' : (voteTotal < 0 ? '#d32f2f' : '#666')
|
||||
const voteTotalSign = voteTotal >= 0 ? '+' : ''
|
||||
|
||||
// Render markdown content to HTML
|
||||
const renderedContent = await renderMarkdownToHtml(versionData.delta?.contenu)
|
||||
|
||||
@@ -306,9 +311,25 @@ export default function PrintButton({versionData, isOutdated = false, size = 'me
|
||||
<strong>Date de création :</strong> ${formatDate(versionData.date_created, 'PPpp', {withTimezone: true})}
|
||||
</div>
|
||||
<div class="metadata">
|
||||
<strong>Statut du vote :</strong>
|
||||
<strong>Statut du vote :</strong>
|
||||
<span class="vote-status">${voteStatus}</span>
|
||||
</div>
|
||||
${voteCounts ? `
|
||||
<div style="margin-top: 15px; padding: 15px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e0e0e0;">
|
||||
<p style="margin: 0 0 10px 0; font-size: 16px; font-weight: bold; color: #333;">
|
||||
📊 Résultats des votes
|
||||
</p>
|
||||
<p style="margin: 5px 0; font-size: 14px;">
|
||||
👍 Votes positifs : <strong style="color: #2e7d32;">${voteCounts.positive}</strong>
|
||||
</p>
|
||||
<p style="margin: 5px 0; font-size: 14px;">
|
||||
👎 Votes négatifs : <strong style="color: #d32f2f;">${voteCounts.negative}</strong>
|
||||
</p>
|
||||
<p style="margin: 10px 0 0 0; font-size: 16px; font-weight: bold;">
|
||||
🏆 Total : <span style="color: ${voteTotalColor};">${voteTotalSign}${voteTotal}</span>
|
||||
</p>
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
|
||||
<div class="content-section">
|
||||
@@ -392,6 +413,11 @@ export default function PrintButton({versionData, isOutdated = false, size = 'me
|
||||
PrintButton.propTypes = {
|
||||
versionData: PropTypes.object.isRequired,
|
||||
isOutdated: PropTypes.bool,
|
||||
voteCounts: PropTypes.shape({
|
||||
positive: PropTypes.number,
|
||||
negative: PropTypes.number,
|
||||
total: PropTypes.number
|
||||
}),
|
||||
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
||||
variant: PropTypes.oneOf(['text', 'outlined', 'contained'])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user