From 6307f89d2df775116c708a880035ca6aeb04efbe Mon Sep 17 00:00:00 2001 From: DoribelTerceroParker Date: Wed, 18 Sep 2024 13:53:08 -0400 Subject: [PATCH] feat(#13): apply css to urgency labels --- src/api/firebase.js | 6 +----- src/components/ListItem.css | 25 +++++++++++++++++++++++++ src/components/ListItem.jsx | 4 +++- src/utils/dates.js | 4 ++-- src/views/List.jsx | 37 ++++--------------------------------- 5 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/api/firebase.js b/src/api/firebase.js index 45daed8..5b3fa10 100644 --- a/src/api/firebase.js +++ b/src/api/firebase.js @@ -10,11 +10,7 @@ import { } from 'firebase/firestore'; import { useEffect, useState } from 'react'; import { db } from './config'; -import { - getFutureDate, - cal, - calculateDaysDifferenceFromNowculateDaysDifferenceFromNow, -} 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 diff --git a/src/components/ListItem.css b/src/components/ListItem.css index 172be81..d034cfc 100644 --- a/src/components/ListItem.css +++ b/src/components/ListItem.css @@ -29,3 +29,28 @@ th { background-color: #3e27ed; border-bottom: 2px solid #ddd; } + +.duesoon { + color: orange; + font-weight: bold; +} + +.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 e0513bd..e956eef 100644 --- a/src/components/ListItem.jsx +++ b/src/components/ListItem.jsx @@ -60,6 +60,8 @@ export function ListItem({ } }; + const urgencyClass = sortCriteria.tag.toLowerCase().replace(/\s/g, ''); + return ( <> @@ -76,7 +78,7 @@ export function ListItem({ {dateLastPurchased ? dateLastPurchased.toDate().toLocaleString() : ''} - {sortCriteria.tag} + {sortCriteria.tag} ); diff --git a/src/utils/dates.js b/src/utils/dates.js index 0611881..020da79 100644 --- a/src/utils/dates.js +++ b/src/utils/dates.js @@ -37,7 +37,7 @@ export function comparePurchaseUrgency(list) { }; inactive.push(item); } else if (days < 60 && days > 0) { - item.sortCriteria = { tag: 'Past due date', daysUntilNextPurchase: days }; + item.sortCriteria = { tag: 'Overdue', daysUntilNextPurchase: days }; overdue.push(item); } else if (days <= 0 && days >= -7) { item.sortCriteria = { tag: 'Due soon', daysUntilNextPurchase: days }; @@ -49,7 +49,7 @@ export function comparePurchaseUrgency(list) { }; future.push(item); } else if (days < -30) { - item.sortCriteria = { tag: 'Due not soon', daysUntilNextPurchase: days }; + item.sortCriteria = { tag: 'Not due soon', daysUntilNextPurchase: days }; future.push(item); } }); diff --git a/src/views/List.jsx b/src/views/List.jsx index 08b6cad..fc72180 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -56,10 +56,10 @@ export function List({ data, listPath }) { - - - - + + + + @@ -84,32 +84,3 @@ export function List({ data, listPath }) { ); } -{ - /* */ -} -// -// ); -// }
ProductBuy NowLast Purchase DateUrgencyProductBuy NowLast Purchase DateUrgency