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

Mark item as purchased & update DB #31

Merged
merged 21 commits into from
Sep 8, 2024
Merged

Conversation

bbland1
Copy link
Collaborator

@bbland1 bbland1 commented Sep 4, 2024

Description

This change adds the ability for a user to mark an item on their list as purchased. When marking the item as purchased the database will be updated with the current date as the new dateLastPurchased and increment the totalPurchases of the item. The list item checks if it has been more than 24 hours since an item was marked as purchased the item will uncheck and be able to be marked as purchased again. If a user tries to mark an item as purchased again in 24 hours it will prevent them from triggering it again.

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

Type
💯 Enhancement
✨ New Feature

Updates

Before

Screenshot 2024-09-05 at 11 46 07 AM

After

Screenshot 2024-09-06 at 1 59 11 PM
My.Movie.mp4

Testing Steps / QA Criteria

  • From your terminal, pull down this branch with git pull origin bb-ma/mark-item-purchased and check that branch out with git checkout bb-ma/mark-item-purchased`
  • Then npm ci to install the newly added dependencies locally and npm start to launch the app.
  • Click one of your lists that has items in it.
  • Click the list navigate link in the nav bar.
  • All items in the list should now have a checkbox to the left of them.
  • Click either the label or the checkbox to mark an item as purchased.
  • Click again and you will get a notification that will say it can't be marked again in a 24 hour period.
  • Open a new tab with the firebase console and navigate to your lists (the unique id associated with you outside of the users collection).
  • Open the list you just marked items purchased on.
  • See that the dateLastPurchased and totalPurchases has been updated.
  • Change the dateLastPurchased to be at least 24 hours and 1 minute in the past from the current dateLastPurchased.
  • Return to the app and notice the checkbox should be unchecked and able to be updated again.

Copy link

github-actions bot commented Sep 4, 2024

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

https://tcl-77-smart-shopping-list--pr31-bb-ma-mark-item-purc-f4pe1tc0.web.app

(expires Sun, 15 Sep 2024 18:20:00 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b77df24030dca7d8b6561cb24957d2273c5e9d72

@bbland1 bbland1 changed the title updated the updateItem func in api to take parameters & use firebase … Mark item as purchased & update DB Sep 5, 2024
@eternalmaha
Copy link
Collaborator

I was looking into the setTimout() built in Javascript method that could be useful for UI purposes of unchecking the checkbox. If we needed to update anything in the backend as well, i'm sure it could be useful to for coordinating with the firebase document.

src/components/ListItem.tsx Outdated Show resolved Hide resolved
@bbland1 bbland1 marked this pull request as ready for review September 6, 2024 18:31
Copy link
Collaborator

@RossaMania RossaMania left a comment

Choose a reason for hiding this comment

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

I like this! Everything is divided up into functions or functional components, and even different files/folders.

src/components/ListItem.tsx Show resolved Hide resolved
src/api/firebase.ts Outdated Show resolved Hide resolved
src/utils/dates.ts Outdated Show resolved Hide resolved
src/utils/dates.ts Outdated Show resolved Hide resolved
src/api/firebase.ts Outdated Show resolved Hide resolved
@tannaurus tannaurus self-requested a review September 7, 2024 15:46
Copy link
Collaborator

@alex-andria alex-andria left a comment

Choose a reason for hiding this comment

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

Great work Brianna and Maha! 🙌 🙌 this definitely was a hefty card that really required you to map out how to connect your local storage with the db in firebase. Really impressed with how you two communicated on Slack and tried different solutions for the acceptance criteria.

Not much I would change on my end besides tightening up the setChecked state and exploring the utility of the TS feature of tagged union types - which you'll definitely see in the workplace that uses TS. Also appreciate y'all updating the README, nice touch!

src/components/ListItem.tsx Show resolved Hide resolved
src/components/ListItem.tsx Show resolved Hide resolved
bbland1 and others added 4 commits September 8, 2024 12:55
Co-authored-by: Maha Ahmed <eternalmaha@users.noreply.github.com>
Co-authored-by: Maha Ahmed <eternalmaha@users.noreply.github.com>
@bbland1 bbland1 merged commit 7bacfe6 into main Sep 8, 2024
2 checks passed
@bbland1 bbland1 deleted the bb-ma/mark-item-purchased branch September 8, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new feature
Projects
None yet
6 participants