diff --git a/src/api/firebase.js b/src/api/firebase.js index 48dd589..0e8c82b 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -186,13 +186,25 @@ export function comparePurchaseUrgency(list) { const days = getDaysBetweenDates(item.dateNextPurchased); if (days >= 60) { //flip the days to negative for inactive items - item.sortCriteria = { tag: 'inactive', daysUntilNextPurchase: -days }; + item.sortCriteria = { + tag: 'No longer active', + daysUntilNextPurchase: -days, + }; inactive.push(item); } else if (days < 60 && days > 0) { - item.sortCriteria = { tag: 'overdue', daysUntilNextPurchase: days }; + item.sortCriteria = { tag: 'Past due date', daysUntilNextPurchase: days }; overdue.push(item); - } else { - item.sortCriteria = { tag: 'future', daysUntilNextPurchase: days }; + } else if (days <= 0 && days >= -7) { + item.sortCriteria = { tag: 'Due soon', daysUntilNextPurchase: days }; + future.push(item); + } else if (days < -7 && days >= -30) { + item.sortCriteria = { + tag: 'Due kind of soon', + daysUntilNextPurchase: days, + }; + future.push(item); + } else if (days < -30) { + item.sortCriteria = { tag: 'Due not soon', daysUntilNextPurchase: days }; future.push(item); } }); diff --git a/src/components/ListItem.css b/src/components/ListItem.css index 492e345..172be81 100644 --- a/src/components/ListItem.css +++ b/src/components/ListItem.css @@ -1,4 +1,4 @@ -.ListItem { +/* .ListItem { display: flex; flex-direction: row; align-items: center; @@ -19,4 +19,13 @@ .item-name { flex-grow: 1; margin-right: 10px; +} */ + +td { + border-bottom: 1px solid whitesmoke; +} + +th { + background-color: #3e27ed; + border-bottom: 2px solid #ddd; } diff --git a/src/components/ListItem.jsx b/src/components/ListItem.jsx index 94eb733..e0513bd 100644 --- a/src/components/ListItem.jsx +++ b/src/components/ListItem.jsx @@ -12,6 +12,7 @@ export function ListItem({ dateLastPurchased, purchaseInterval, dateCreated, + sortCriteria, }) { const [purchased, setPurchased] = useToggle(false); const [isDisabled, setIsDisabled] = useState(false); @@ -61,18 +62,22 @@ export function ListItem({ return ( <> -
  • -
    {name}
    - - - {dateLastPurchased ? dateLastPurchased.toDate().toLocaleString() : ''} -
  • + + {name} + + + + + {dateLastPurchased ? dateLastPurchased.toDate().toLocaleString() : ''} + + {sortCriteria.tag} + ); } diff --git a/src/views/List.jsx b/src/views/List.jsx index 7e4d6e5..ad2c9dd 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -9,23 +9,17 @@ export function List({ data, listPath }) { setSearchInput(e.target.value); }; - let sorted = comparePurchaseUrgency(data); - let names = []; - sorted.forEach((item) => { - names.push(item.name); - }); - console.log('names', names); - const clearSearchInput = () => { setSearchInput(''); }; - const filterList = data.filter((item) => { + const sortedByUrgency = comparePurchaseUrgency(data); + + const filterList = sortedByUrgency.filter((item) => { return searchInput ? item.name.toLowerCase().includes(searchInput.toLowerCase()) : item; }); - const listInfo = comparePurchaseUrgency(filterList); return ( <> @@ -58,7 +52,40 @@ export function List({ data, listPath }) { )} - */ } +// +// ); +// }