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 statusConfig = getStatusConfig(status)
|
||||||
const userDisplayName = version.user_created?.split('-')[0] || 'Système'
|
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 handleCompareClick = async () => {
|
||||||
const comparisonData = await compareVersion({
|
const comparisonData = await compareVersion({
|
||||||
accessToken,
|
accessToken,
|
||||||
@@ -171,12 +176,22 @@ function VersionCard({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box sx={{display: 'flex', gap: 1}}>
|
||||||
<Chip
|
<Chip
|
||||||
label={statusConfig.label}
|
label={statusConfig.label}
|
||||||
color={statusConfig.chipColor}
|
color={statusConfig.chipColor}
|
||||||
size='small'
|
size='small'
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
/>
|
/>
|
||||||
|
{isVoteDisabled && (
|
||||||
|
<Chip
|
||||||
|
label='Vote fermé'
|
||||||
|
color='error'
|
||||||
|
size='small'
|
||||||
|
variant='outlined'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Typography variant='body2' color='text.secondary' sx={{mb: 2, fontStyle: 'italic'}}>
|
<Typography variant='body2' color='text.secondary' sx={{mb: 2, fontStyle: 'italic'}}>
|
||||||
@@ -204,7 +219,12 @@ function VersionCard({
|
|||||||
size='small'
|
size='small'
|
||||||
variant='text'
|
variant='text'
|
||||||
/>
|
/>
|
||||||
<VoteButtons hasCountsVisible versionId={version.id} onVoteResult={onVoteResult} />
|
<VoteButtons
|
||||||
|
hasCountsVisible
|
||||||
|
versionId={version.id}
|
||||||
|
isDisabled={isVoteDisabled}
|
||||||
|
onVoteResult={onVoteResult}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user