File tree 3 files changed +44
-2
lines changed
3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import { models } from 'cozy-client'
5
+
6
+ import Typography from '../../Typography'
7
+ import { useI18n } from '../../I18n'
8
+ import { formatLocallyDistanceToNow } from '../../I18n/format'
9
+
10
+ const { computeExpirationDate, isExpired } = models . paper
11
+
12
+ const ExpirationAnnotation = ( { file } ) => {
13
+ const { t } = useI18n ( )
14
+
15
+ if ( isExpired ( file ) ) {
16
+ return (
17
+ < Typography component = "span" variant = "inherit" color = "error" >
18
+ { t ( 'Viewer.panel.qualification.expired' ) }
19
+ </ Typography >
20
+ )
21
+ }
22
+
23
+ const expirationDate = computeExpirationDate ( file )
24
+
25
+ return (
26
+ < Typography component = "span" variant = "inherit" className = "u-warning" >
27
+ { t ( 'Viewer.panel.qualification.expiresIn' , {
28
+ duration : formatLocallyDistanceToNow ( expirationDate )
29
+ } ) }
30
+ </ Typography >
31
+ )
32
+ }
33
+
34
+ ExpirationAnnotation . propTypes = {
35
+ file : PropTypes . object . isRequired
36
+ }
37
+
38
+ export default ExpirationAnnotation
Original file line number Diff line number Diff line change 72
72
"copy" : " Copy" ,
73
73
"copyClipboard" : " Copy to clipboard" ,
74
74
"edit" : " Edit"
75
- }
75
+ },
76
+ "expired" : " Expired" ,
77
+ "expiresIn" : " Expires in %{duration}"
76
78
},
77
79
"title" : " Useful information"
78
80
},
Original file line number Diff line number Diff line change 72
72
"copy" : " Copier" ,
73
73
"copyClipboard" : " Copier dans le presse-papier" ,
74
74
"edit" : " Modifier"
75
- }
75
+ },
76
+ "expired" : " Expiré" ,
77
+ "expiresIn" : " Expire dans %{duration}"
76
78
},
77
79
"title" : " Informations utiles"
78
80
},
You can’t perform that action at this time.
0 commit comments