@@ -8,16 +8,43 @@ import { DeleteIconWithTooltip, tooltipStyle } from './DeleteIconWithTooltip';
88import {
99 ListItem as MaterialListItem ,
1010 Tooltip ,
11+ IconButton ,
1112 ListItemButton ,
1213 ListItemIcon ,
1314 ListItemText ,
1415 Checkbox ,
1516} from '@mui/material' ;
17+ import {
18+ Restore as OverdueIcon ,
19+ RestartAlt as SoonIcon ,
20+ RadioButtonUnchecked as KindOfSoonIcon ,
21+ RemoveCircle as NotSoonIcon ,
22+ RadioButtonChecked as InactiveIcon ,
23+ } from '@mui/icons-material' ;
1624
1725import './ListItem.css' ;
1826
1927const currentDate = new Date ( ) ;
2028
29+ const urgencyStatusIcons = {
30+ overdue : OverdueIcon ,
31+ soon : SoonIcon ,
32+ kindOfSoon : KindOfSoonIcon ,
33+ notSoon : NotSoonIcon ,
34+ inactive : InactiveIcon ,
35+ } ;
36+
37+ const urgencyStatusStyle = {
38+ fontSize : '2.5rem' ,
39+ color : 'white' ,
40+ } ;
41+
42+ const toolTipStyle = {
43+ fontSize : '1.5rem' ,
44+ marginBlockStart : '0' ,
45+ marginBlockEnd : '0' ,
46+ } ;
47+
2148const calculateIsPurchased = ( dateLastPurchased ) => {
2249 if ( ! dateLastPurchased ) {
2350 return false ;
@@ -30,7 +57,7 @@ const calculateIsPurchased = (dateLastPurchased) => {
3057 return currentDate < oneDayLater ;
3158} ;
3259
33- export function ListItem ( { item, listPath } ) {
60+ export function ListItem ( { item, listPath, itemUrgencyStatus } ) {
3461 const { open, isOpen, toggleDialog } = useConfirmDialog ( ) ;
3562 const [ isPurchased , setIsPurchased ] = useState ( ( ) =>
3663 calculateIsPurchased ( item . dateLastPurchased ) ,
@@ -69,6 +96,8 @@ export function ListItem({ item, listPath }) {
6996 return ;
7097 } ;
7198
99+ const UrgencyStatusIcon = urgencyStatusIcons [ itemUrgencyStatus ] ;
100+
72101 const props = {
73102 handleDelete : handleDeleteItem ,
74103 title : `Are you sure you want to delete ${ name } ?` ,
@@ -84,6 +113,17 @@ export function ListItem({ item, listPath }) {
84113 < >
85114 { open && < ConfirmDialog props = { props } /> }
86115 < MaterialListItem className = "ListItem" >
116+ { UrgencyStatusIcon && (
117+ < Tooltip
118+ title = { < p style = { toolTipStyle } > { itemUrgencyStatus } </ p > }
119+ placement = "left"
120+ arrow
121+ >
122+ < IconButton aria-label = { itemUrgencyStatus } >
123+ < UrgencyStatusIcon sx = { urgencyStatusStyle } fontSize = "large" />
124+ </ IconButton >
125+ </ Tooltip >
126+ ) }
87127 < ListItemButton role = { undefined } onClick = { handleChange } dense >
88128 < ListItemIcon >
89129 < Tooltip
0 commit comments