Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #13: Sort Items by Purchase Urgency #30

Merged
merged 8 commits into from
Sep 21, 2024
Merged

Conversation

dterceroparker
Copy link
Member

@dterceroparker dterceroparker commented Sep 16, 2024

Description

This feature sorts shopping list items by urgency to help users plan their purchases. Items are grouped into:

  • Due soon (7 days or fewer)
  • Due kind of soon (7–30 days)
  • Not due soon (30+ days)
  • Overdue (0-60 days since predicted next purchase date)
  • Inactive (60+ days since last purchase)

Changes

  • Added urgency indicators to each item without relying solely on color.
  • Implemented comparePurchaseUrgency in dates.js to:

Sort inactive items last.
Sort items by days until purchase.
Sort items alphabetically if urgency is the same.
Overdue items (past their purchase date but not inactive) are sorted to the top.
Overdue items are indicated in the UI.

Related Issue

Closes #13

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
  • 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

Type of Changes

Enhancement
Feature
Accessibility

Updates

After

Screen Shot 2024-09-18 at 2 05 32 PM

Testing Steps / QA Criteria

  • Please log in using your Gmail credentials
  • We have shared the SortTest list which should appear on the Home page

SortTest list reflects all urgency categories. Please examine that they are ordered from (bottom to top) inactive, not soon, kind of soon, due soon, and overdue.

  • Please feel free to experiment with your own lists to verify that purchasing an item changes its urgency.

export function comparePurchaseUrgency

dates.js: update param name and logic to handle future and past dates

List.jsx: import comparePurchaseUrgency
Copy link

github-actions bot commented Sep 16, 2024

Visit the preview URL for this PR (updated for commit 8279ed4):

https://tcl-74-smart-shopping-list--pr30-dtp-nr-sorting-d0os35i8.web.app

(expires Sat, 28 Sep 2024 16:15:01 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 79d73546692f99aad8468c28e36db434e2c190ac

@dterceroparker dterceroparker changed the title Issue #13: Implement sort list by purchase history Issue #13: Implement Sort List by Purchase Date Urgency Sep 16, 2024
NickRoccodev11 and others added 3 commits September 16, 2024 16:08
filter shopping list to separate out past purchase dates and pending purchase dates into two lists

append the lists to eachother so overdue dates come first
…ping list items based on urgency

Categories are: inactive, overdue, and future.

Overdue items appear first, followed by future dates, and finally inactive items.
@dterceroparker dterceroparker changed the title Issue #13: Implement Sort List by Purchase Date Urgency Issue #13: Sort Items by Purchase Urgency Sep 18, 2024
@dterceroparker dterceroparker added accessibility enhancement New feature or request labels Sep 18, 2024
@dterceroparker dterceroparker marked this pull request as ready for review September 18, 2024 18:16
Copy link
Contributor

@stacy-tech stacy-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it, and everything is functioning as expected. The urgency indicator works well, and updates the items purchase urgency time smoothly- great job guy! 🎉

Copy link
Collaborator

@shuveksha-tuladhar shuveksha-tuladhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NickRoccodev11 @dterceroparker Great work! The functionality is excellent. For the UI, perhaps we could revisit the color choices that may work for both dark and light modes to improve visibility, especially in the lighter mode. We could consider creating an issue to address this in the future.
image

@@ -10,7 +10,7 @@ import {
} from 'firebase/firestore';
import { useEffect, useState } from 'react';
import { db } from './config';
import { getFutureDate, getDaysBetweenDates } from '../utils';
import { getFutureDate, calculateDaysDifferenceFromNow } from '../utils';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update from office hours! 👍

Copy link
Collaborator

@meganesu meganesu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in the deploy preview. Looks good! 🥳 Great work y'all, this was a tough one.

+1 to @shuveksha-tuladhar's comment about color contrast. Here's a tool you can use to check the contrast ratio between two colors: https://colorkit.co/contrast-checker/

Also some web browser dev tools have a way you can inspect an element's color to see what the contrast ratio is. Here's what it looks like in Firefox:
Screenshot 2024-09-20 at 8 15 33 PM

src/utils/dates.js Show resolved Hide resolved
Copy link
Collaborator

@jtkabenni jtkabenni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work you all! This one was a tough one to end on. I just had a few comments but otherwise it looks great, and you did a great job pulling functions into utils and commenting out what your code is doing.

src/utils/dates.js Show resolved Hide resolved
src/components/ListItem.jsx Show resolved Hide resolved
@dterceroparker
Copy link
Member Author

Tested in the deploy preview. Looks good! 🥳 Great work y'all, this was a tough one.

+1 to @shuveksha-tuladhar's comment about color contrast. Here's a tool you can use to check the contrast ratio between two colors: https://colorkit.co/contrast-checker/

Also some web browser dev tools have a way you can inspect an element's color to see what the contrast ratio is. Here's what it looks like in Firefox: Screenshot 2024-09-20 at 8 15 33 PM

Thank you, @shuveksha-tuladhar and @meganesu! We used dark mode and we overlooked testing in light mode. I appreciate the resource you shared, Megan. I'll keep both modes in mind for future testing.

@dterceroparker dterceroparker merged commit 55e8bc8 into main Sep 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility enhancement New feature or request
Projects
None yet
6 participants