-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] due date display in Tasks list (#4647)
- Loading branch information
Showing
3 changed files
with
49 additions
and
48 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
opencti-platform/opencti-front/src/components/ItemDueDate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import Chip from '@mui/material/Chip'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { useFormatter } from './i18n'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
chip: { | ||
borderRadius: 5, | ||
}, | ||
chipInList: { | ||
fontSize: 12, | ||
height: 20, | ||
float: 'left', | ||
width: 120, | ||
borderRadius: 5, | ||
}, | ||
})); | ||
|
||
const ItemDueDate = ({ due_date, variant }: { due_date: string | null, variant: string }) => { | ||
const { fld, fldt } = useFormatter(); | ||
const classes = useStyles(); | ||
const isoDate = new Date().toISOString(); | ||
const style = variant === 'inList' ? classes.chipInList : classes.chip; | ||
const label = variant === 'inList' ? fld(due_date) : fldt(due_date); | ||
if (due_date) { | ||
return ( | ||
<Chip | ||
classes={{ root: style }} | ||
variant="outlined" | ||
label={label} | ||
color={due_date < isoDate ? 'error' : 'info'} | ||
/> | ||
); | ||
} | ||
return ( | ||
<>-</> | ||
); | ||
}; | ||
|
||
export default ItemDueDate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters