the-collab-lab / tcl-65-smart-shopping-list

1 stars 1 forks source link

12. 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. #12

Closed fullybaked closed 1 year ago

fullybaked commented 1 year ago

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:

  1. Need to buy soon (7 days or fewer until the next purchase)
  2. Need to buy kind of soon (between 7 & 30 days until the next purchase)
  3. Need to buy not soon (30 days or more until the next purchase)
  4. 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

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”.

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:

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:

  1. Whether the item is active or inactive, then
  2. By the number of days until its dateNextPurchased, and
  3. 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.

nitin-pandita commented 1 year ago

Hey @fullybaked I would like to give it a try

fullybaked commented 1 year ago

@nitin-pandita thanks so much for your interest, but this issue (and this whole repo) are for one of the teams in the current cohort of The Collab Lab and our participants will be working on it as part of the programme.

If you're interested in issues, or projects like this, you can check out The Collab Lab, and apply if you'd like to participate. We'll be running more cohorts next year.

nitin-pandita commented 1 year ago

e Collab Lab, and

@fullybaked Thank you for the reply, i would to participate