Skip to content

Commit

Permalink
feat(mespapiers): Add expiration annotations to paper items
Browse files Browse the repository at this point in the history
  • Loading branch information
PolariTOON committed Dec 7, 2022
1 parent 7c6c8e2 commit b493d79
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/cozy-mespapiers-lib/src/components/Papers/PaperItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate, useLocation } from 'react-router-dom'
import PropTypes from 'prop-types'
import cx from 'classnames'

import { useClient } from 'cozy-client'
import { models, useClient } from 'cozy-client'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon'
Expand All @@ -18,6 +18,9 @@ import { makeStyles } from 'cozy-ui/transpiled/react/styles'

import { useMultiSelection } from '../Hooks/useMultiSelection'
import RenameInput from './Renaming/RenameInput'
import ExpirationAnnotation from './ExpirationAnnotation'

const { isExpired, isExpiringSoon } = models.paper

const useStyles = makeStyles(() => ({
checkbox: {
Expand Down Expand Up @@ -84,9 +87,19 @@ const PaperItem = ({
)
}

const secondaryText = `${contactNames ? contactNames : ''}${
contactNames && paperDate ? ' · ' : ''
}${paperDate ? paperDate : ''}`
const secondaryText = (
<>
{contactNames ? contactNames : ''}
{contactNames && paperDate ? ' · ' : ''}
{paperDate ? paperDate : ''}
{(isExpired(paper) || isExpiringSoon(paper)) && (
<>
{contactNames || paperDate ? ' · ' : ''}
<ExpirationAnnotation file={paper} />
</>
)}
</>
)

return (
<>
Expand Down

0 comments on commit b493d79

Please sign in to comment.