diff --git a/src/api/firebase.js b/src/api/firebase.js
index 394860c..7fd8e7f 100644
--- a/src/api/firebase.js
+++ b/src/api/firebase.js
@@ -11,7 +11,7 @@ import {
} from 'firebase/firestore';
import { useEffect, useState } from 'react';
import { db } from './config';
-import { getFutureDate, getDaysBetweenDates } from '../utils';
+import { getFutureDate, calculateDaysDifferenceFromNow } from '../utils';
import { calculateEstimate } from '@the-collab-lab/shopping-list-utils';
/**
* A custom hook that subscribes to the user's shopping lists in our Firestore
@@ -210,9 +210,9 @@ export async function updateItem(
let daysSinceLastPurchase;
if (dateLastPurchased) {
- daysSinceLastPurchase = getDaysBetweenDates(dateLastPurchased);
+ daysSinceLastPurchase = calculateDaysDifferenceFromNow(dateLastPurchased);
} else {
- daysSinceLastPurchase = getDaysBetweenDates(dateCreated);
+ daysSinceLastPurchase = calculateDaysDifferenceFromNow(dateCreated);
}
// Calculate days until next purchase
diff --git a/src/components/ListItem.css b/src/components/ListItem.css
index 492e345..6a4200d 100644
--- a/src/components/ListItem.css
+++ b/src/components/ListItem.css
@@ -1,22 +1,33 @@
-.ListItem {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- padding: 8px;
- border-bottom: 1px solid var(--color-border);
- font-size: 1.2em;
+td {
+ border-bottom: 1px solid whitesmoke;
}
-.ListItem-checkbox {
- accent-color: var(--color-accent);
+th {
+ background-color: #3e27ed;
+ border-bottom: 2px solid #ddd;
}
-.ListItem-label {
- margin-left: 0.2em;
+.duesoon {
+ color: orange;
+ font-weight: bold;
}
-.item-name {
- flex-grow: 1;
- margin-right: 10px;
+.duekindofsoon {
+ color: yellow;
+ font-weight: bold;
+}
+
+.notduesoon {
+ color: green;
+ font-weight: bold;
+}
+
+.nolongeractive {
+ color: gray;
+ font-weight: bold;
+}
+
+.overdue {
+ color: red;
+ font-weight: bold;
}
diff --git a/src/components/ListItem.jsx b/src/components/ListItem.jsx
index d9e7e23..4327f20 100644
--- a/src/components/ListItem.jsx
+++ b/src/components/ListItem.jsx
@@ -12,6 +12,7 @@ export function ListItem({
dateLastPurchased,
purchaseInterval,
dateCreated,
+ sortCriteria,
setMessage,
}) {
const [purchased, setPurchased] = useToggle(false);
@@ -60,10 +61,11 @@ export function ListItem({
}
}
};
-
+
+
// handleDelete Function
const handleDelete = async () => {
- const deleteConfirm = window.confirm(
+ const deleteConfirm = window.confirm(
`Are you sure you want to delete ${name}?`,
);
@@ -77,23 +79,32 @@ export function ListItem({
}
};
+ const urgencyClass = sortCriteria.tag.toLowerCase().replace(/\s/g, '');
+
return (
<>
-
- {name}
-
-
- {dateLastPurchased ? dateLastPurchased.toDate().toLocaleString() : ''}
-
)}
-
- {filterList.length ? (
- filterList.map((item) => {
- return (
+ {filterList.length ? (
+
+
+
+ Product |
+ Buy Now |
+ Last Purchase Date |
+ Urgency |
+
+
+
+ {filterList.map((item) => (
- );
- })
- ) : (
- -
- {' '}
- No items found! Add item
-
- )}
+ ))}
+
+
+ ) : (
+ No items to display
+ )}
{message}
-
+
>
);
}