1
1
import React , { forwardRef } from 'react'
2
2
import PropTypes from 'prop-types'
3
3
4
+ import { models } from 'cozy-client'
5
+
4
6
import ListItem from '../../MuiCozyTheme/ListItem'
5
7
import ListItemSecondaryAction from '../../MuiCozyTheme/ListItemSecondaryAction'
6
8
import IconButton from '../../IconButton'
7
9
import Icon from '../../Icon'
8
10
import Dots from '../../Icons/Dots'
11
+ import Typography from '../../Typography'
12
+ import ExpirationAnnotation from '../components/ExpirationAnnotation'
9
13
import QualificationListItemText from './QualificationListItemText'
10
14
import { useI18n } from '../../I18n'
11
15
import { formatDate } from '../helpers'
12
16
17
+ const { isExpired, isExpiringSoon } = models . paper
18
+
13
19
const QualificationListItemDate = forwardRef (
14
- ( { formatedMetadataQualification, toggleActionsMenu } , ref ) => {
20
+ ( { file , formatedMetadataQualification, toggleActionsMenu } , ref ) => {
15
21
const { t, f, lang } = useI18n ( )
16
22
const { name, value } = formatedMetadataQualification
17
23
const formattedDate = value
@@ -22,7 +28,21 @@ const QualificationListItemDate = forwardRef(
22
28
< ListItem className = { 'u-pl-2 u-pr-3' } >
23
29
< QualificationListItemText
24
30
primary = { t ( `Viewer.panel.qualification.date.title.${ name } ` ) }
25
- secondary = { formattedDate }
31
+ secondary = {
32
+ < >
33
+ < Typography component = "span" variant = "inherit" >
34
+ { formattedDate }
35
+ </ Typography >
36
+ { ( isExpired ( file ) || isExpiringSoon ( file ) ) && (
37
+ < >
38
+ < Typography component = "span" variant = "inherit" >
39
+ { ' · ' }
40
+ </ Typography >
41
+ < ExpirationAnnotation file = { file } />
42
+ </ >
43
+ ) }
44
+ </ >
45
+ }
26
46
disabled = { ! value }
27
47
/>
28
48
< ListItemSecondaryAction >
@@ -41,6 +61,7 @@ const QualificationListItemDate = forwardRef(
41
61
QualificationListItemDate . displayName = 'QualificationListItemDate'
42
62
43
63
QualificationListItemDate . propTypes = {
64
+ file : PropTypes . object . isRequired ,
44
65
formatedMetadataQualification : PropTypes . shape ( {
45
66
name : PropTypes . string ,
46
67
value : PropTypes . string
0 commit comments