You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
13. As a user, I want to view a list of my shopping list items in order of how soon I am likely to need to buy each of them again so that it’s clear what I need to buy soon
#13
Closed
8 tasks done
fullybaked opened this issue
Aug 7, 2024
· 0 comments
Sorting items by how soon the user might need to buy them will make it easier for the user to identify what they need to buy, which will in turn help them better plan their shopping trips. To that end, we will be sorting items into 4 possible groups, according to how urgently the user should buy the item:
Need to buy soon (7 days or fewer until the next purchase)
Need to buy kind of soon (between 7 & 30 days until the next purchase)
Need to buy not soon (30 days or more until the next purchase)
Inactive (60 days have passed since the last purchase)
To implement this feature, your team will need to create some new UI elements so the user knows how their items are sorted and write some logic behind-the-scenes to perform the sorting itself. Read the acceptance criteria and our notes carefully to be sure you understand the tasks at hand, and don’t be afraid to reach out to the rest of your team, and your mentors if you need help. You’ve got this!
Acceptance criteria
Items in the list are shown with an indicator that tells the user they should buy the item “soon”, “kind of soon”, or “not soon”; or that the item is “inactive”
This urgency indicator does not rely on only color
api/firestore.js exports a new comparePurchaseUrgency function with the following behaviors
sorts inactive items last, then
sorts items in ascending order of days until purchase, and
sorts items with the same days until purchase alphabetically
A stretch goal
If you complete all of the previous acceptance criteria, consider what happens when an item’s dateNextPurchased has passed, but it isn’t yet inactive. Let’s call that item “overdue”.
Extend the functionality of comparePurchaseUrgency to sort “overdue” items to the top of the list
Indicate in your UI when an item is overdue
Notes
There's a lot to do for this issue! Read this section for some ideas about how to approach the tasks ahead. The getDaysBetweenDates function in src/utils/dates.js will be useful!
Remember: The dates in the Firestore database are special Timestamp objects. You’ll need to call their toDate() method to get a JavaScript Date that we can work with.
Indicating purchase urgency in the UI
It’s tempting to use colors or icons to indicate how soon the user should buy an item. Keep in mind:
If you use only color, a colorblind user won’t be able to tell the difference between urgency indicators
If you use icons, you have to teach users what those icons mean
With these constraints, it’s probably best to render plain text, like “soon”, “kind of soon”, etc. in order to show urgency. You can still use color alongside that text, and the design of where that text goes is up to you!
Sorting the list
We’re sorting by multiple criteria:
Whether the item is active or inactive, then
By the number of days until its dateNextPurchased, and
Alphabetically by name, if they have the same number of days until purchase
Sorting by multiple criteria can be tricky! Refer to the MDN docs for Array.prototype.sort and refresh yourself on how to write compare functions so you can write the comparePurchaseUrgency function.
The text was updated successfully, but these errors were encountered:
Summary
Sorting items by how soon the user might need to buy them will make it easier for the user to identify what they need to buy, which will in turn help them better plan their shopping trips. To that end, we will be sorting items into 4 possible groups, according to how urgently the user should buy the item:
To implement this feature, your team will need to create some new UI elements so the user knows how their items are sorted and write some logic behind-the-scenes to perform the sorting itself. Read the acceptance criteria and our notes carefully to be sure you understand the tasks at hand, and don’t be afraid to reach out to the rest of your team, and your mentors if you need help. You’ve got this!
Acceptance criteria
api/firestore.js
exports a newcomparePurchaseUrgency
function with the following behaviorsA stretch goal
If you complete all of the previous acceptance criteria, consider what happens when an item’s
dateNextPurchased
has passed, but it isn’t yet inactive. Let’s call that item “overdue”.comparePurchaseUrgency
to sort “overdue” items to the top of the listNotes
There's a lot to do for this issue! Read this section for some ideas about how to approach the tasks ahead. The
getDaysBetweenDates
function insrc/utils/dates.js
will be useful!Remember: The dates in the Firestore database are special
Timestamp
objects. You’ll need to call theirtoDate()
method to get a JavaScript Date that we can work with.Indicating purchase urgency in the UI
It’s tempting to use colors or icons to indicate how soon the user should buy an item. Keep in mind:
With these constraints, it’s probably best to render plain text, like “soon”, “kind of soon”, etc. in order to show urgency. You can still use color alongside that text, and the design of where that text goes is up to you!
Sorting the list
We’re sorting by multiple criteria:
dateNextPurchased
, andSorting by multiple criteria can be tricky! Refer to the MDN docs for
Array.prototype.sort
and refresh yourself on how to write compare functions so you can write thecomparePurchaseUrgency
function.The text was updated successfully, but these errors were encountered: