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 #9 - Marking item as purchased #28

Merged
merged 20 commits into from
Mar 3, 2024
Merged

Conversation

andiedoescode
Copy link
Collaborator

@andiedoescode andiedoescode commented Feb 29, 2024

Description

This PR enables a user to mark a list item as purchased and initiates a timer to uncheck a purchased item after 24 hours so they may buy it again.

  • Created the updateItem function in the firebase.js API
  • Checkbox type input next to each list item
  • setTimeout used to uncheck a purchased item after 24 hours
  • Change handler and useState to determine if an item has been checked and call updateItem function

Related Issue

Closes #9

Acceptance Criteria

  • The ListItem component renders a checkbox with a semantic <label>.
  • Checking off the item in the UI also updates the dateLastPurchased and totalPurchases properties on the corresponding Firestore document
  • The item is shown as checked for 24 hours after the purchase is made (i.e. we assume the user does not need to buy the item again for at least 1 day). After 24 hours, the item unchecks itself so the user can buy it again.
  • The updateItem function in firebase.js has been filled out, and sends updates to the firestore database when an item is checked

Type of Changes

New feature

Updates

Before

image

After

image

Testing Steps / QA Criteria

  1. Sign in and select the dinner shopping list
  2. Navigate to List view
  3. Verify that clicking the item name or pressing tab on the keyboard highlights the checkbox for an item
  4. In Firebase, open the dinner list, and open an item to view the item's totalPurchases and dateLastPurchased.
  5. In the app, click on an item's checkbox. Verify in Firebase that the item's totalPurchases has increased by one and that the dateLastPurchased has been updated to the current date and time.
  6. Verify that unchecking the item decreases the totalPurchases by one, and updates dateLastPurchased to null.
  7. In Firebase, change the date for dateLastPurchased to more than a day previous. Confirm that upon List page refresh, the item is unchecked if dateLastPurchased is more than a day prior.

Copy link

github-actions bot commented Feb 29, 2024

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

https://tcl-68-smart-shopping-list--pr28-dg-ap-purchase-item-bslrsggv.web.app

(expires Sun, 10 Mar 2024 19:19:13 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 8cb5d089a99ba9972009993f4dd31796b0cbda84

src/components/ListItem.jsx Outdated Show resolved Hide resolved
src/components/ListItem.jsx Outdated Show resolved Hide resolved
src/components/ListItem.jsx Outdated Show resolved Hide resolved
src/components/ListItem.jsx Outdated Show resolved Hide resolved
src/api/firebase.js Outdated Show resolved Hide resolved
@andiedoescode andiedoescode changed the title Dg ap purchase item Issue $9 - Marking item as purchased Feb 29, 2024
@andiedoescode andiedoescode changed the title Issue $9 - Marking item as purchased Issue #9 - Marking item as purchased Feb 29, 2024
@andiedoescode andiedoescode marked this pull request as ready for review March 1, 2024 01:11
@andiedoescode andiedoescode requested review from etiry and sdmisra March 1, 2024 01:11
etiry
etiry previously approved these changes Mar 1, 2024
Copy link
Collaborator

@etiry etiry left a comment

Choose a reason for hiding this comment

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

Great job working through what was (imo) definitely the trickier of the two issues for the week!

src/components/ListItem.jsx Outdated Show resolved Hide resolved
src/api/firebase.js Show resolved Hide resolved
src/components/ListItem.jsx Show resolved Hide resolved
sdmisra
sdmisra previously approved these changes Mar 1, 2024
Copy link
Collaborator

@sdmisra sdmisra left a comment

Choose a reason for hiding this comment

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

Fantastic work, this absolute seemed like a tricky issue to solve and I like the way you two went about doing just that. Added a question about the timer, but things look good to me overall!

luisaugusto
luisaugusto previously approved these changes Mar 1, 2024
@andiedoescode andiedoescode dismissed stale reviews from luisaugusto, sdmisra, and etiry via d8346dc March 3, 2024 01:09
@andiedoescode andiedoescode requested a review from sdmisra March 3, 2024 02:40
sdmisra
sdmisra previously approved these changes Mar 3, 2024
cafloyd
cafloyd previously approved these changes Mar 3, 2024
@DevinaG007 DevinaG007 dismissed stale reviews from cafloyd and sdmisra via 79c8fb5 March 3, 2024 16:24
@DevinaG007 DevinaG007 requested review from sdmisra and cafloyd March 3, 2024 17:15
raaynaldo
raaynaldo previously approved these changes Mar 3, 2024
@DevinaG007 DevinaG007 requested a review from raaynaldo March 3, 2024 19:19
@raaynaldo
Copy link
Collaborator

Thanks for the update. Good job!

@DevinaG007 DevinaG007 merged commit 166fd84 into main Mar 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants