fix: ajouté vérification délai vote dans VersionTimeline
- Calcul isVoteDisabled basé sur 3 jours après création - Désactivation VoteButtons pour versions anciennes - Chip visuel "Vote fermé" pour versions expirées - Cohérence avec VersionPage et VersionComparison
This commit is contained in:
@@ -116,6 +116,11 @@ function VersionCard({
|
||||
const statusConfig = getStatusConfig(status)
|
||||
const userDisplayName = version.user_created?.split('-')[0] || 'Système'
|
||||
|
||||
// Check if voting is disabled (after 3 days)
|
||||
const createdAt = new Date(version.date_created)
|
||||
const threeDaysAgo = new Date(Date.now() - (3 * 24 * 60 * 60 * 1000))
|
||||
const isVoteDisabled = createdAt < threeDaysAgo
|
||||
|
||||
const handleCompareClick = async () => {
|
||||
const comparisonData = await compareVersion({
|
||||
accessToken,
|
||||
@@ -171,12 +176,22 @@ function VersionCard({
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<Chip
|
||||
label={statusConfig.label}
|
||||
color={statusConfig.chipColor}
|
||||
size='small'
|
||||
variant='outlined'
|
||||
/>
|
||||
<Box sx={{display: 'flex', gap: 1}}>
|
||||
<Chip
|
||||
label={statusConfig.label}
|
||||
color={statusConfig.chipColor}
|
||||
size='small'
|
||||
variant='outlined'
|
||||
/>
|
||||
{isVoteDisabled && (
|
||||
<Chip
|
||||
label='Vote fermé'
|
||||
color='error'
|
||||
size='small'
|
||||
variant='outlined'
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<Typography variant='body2' color='text.secondary' sx={{mb: 2, fontStyle: 'italic'}}>
|
||||
@@ -204,7 +219,12 @@ function VersionCard({
|
||||
size='small'
|
||||
variant='text'
|
||||
/>
|
||||
<VoteButtons hasCountsVisible versionId={version.id} onVoteResult={onVoteResult} />
|
||||
<VoteButtons
|
||||
hasCountsVisible
|
||||
versionId={version.id}
|
||||
isDisabled={isVoteDisabled}
|
||||
onVoteResult={onVoteResult}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</CardContent>
|
||||
|
||||
Reference in New Issue
Block a user