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

Eb ar estimate next purchase date issue 11 #28

Merged
merged 9 commits into from
Sep 16, 2024

Conversation

arandel1
Copy link
Collaborator

@arandel1 arandel1 commented Sep 15, 2024

Description

  • When a user checks a checkbox, Firebase updates with a new date in the dateNextPurchased field
  • dateNextPurchased uses the calculateEstimate function that takes into consideration three arguments: previousEstimate, daysSinceLastPurchase, and totalPurchases to give the user a more tailored dateNextPurchased estimate.

Related Issue

closes 11

Acceptance Criteria

  • When the user purchases an item, the item’s dateNextPurchased property is calculated using the calculateEstimate function and saved to the Firestore database
  • dateNextPurchased is saved as a date, not a number
  • A getDaysBetweenDates function is exported from utils/dates.js and imported into api/firebase.js
  • This function takes two JavaScript Dates and return the number of days that have passed between them

Type of Changes

enhancement

Updates

Before

Screen Shot 2024-09-14 at 11 43 59 PM Screen Shot 2024-09-14 at 11 44 17 PM
  • When user adds grapefruit to their list, dateNextPurchased is populated with a date that is days selected when adding an item (soon, kind of soon, not soon).
  • Example: grapefruit is added on September 14, and dateNextPurchased is set to September 28

After

Screen Shot 2024-09-14 at 11 45 35 PM
  • When user adds lemons to their list, dateNextPurchased is populated with a date that calculates the user's shopping habits. If the user adds the item and checks it off immediately, dateNextPurchased takes into account the user buying the item once and one day later, and how often the user purchases the item.

Testing Steps / QA Criteria

  • Pull from eb-ar-estimate-next-purchase-date-issue-11 branch
  • Add an item and check the dateNextPurchase and dateLastPurchase
  • Check that item off the list and see the dateNextPurchase will be to the next day.

EmmaBin and others added 5 commits September 12, 2024 08:33
…n whole numbers. checkboxes are not staying checked. need to get dateLastPurchased and dateNextPurchased running.
…s correctly updating dateLastPurchased and totalPurchase
… field fills with a date thats calculated using calculateEstimate function
Copy link

github-actions bot commented Sep 15, 2024

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

https://tcl-76-smart-shopping-list--pr28-eb-ar-estimate-next-dg99jllp.web.app

(expires Mon, 23 Sep 2024 20:46:05 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 512b1a88be8ae05fd3e727b99332819df760271d

EmmaBin and others added 3 commits September 14, 2024 23:29
- Ensure dateLastPurchased is updated when an item is checked.
- Update dateNextPurchased using getFutureDate function.
Copy link
Collaborator

@MarcosPerez16 MarcosPerez16 left a comment

Choose a reason for hiding this comment

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

Did some testing and everything is working. I went ahead and added an item and all the date props in firebase are updating correctly. When I check the item, dateNextPurchased updates to the next day.

Copy link
Collaborator

@sar-mko sar-mko left a comment

Choose a reason for hiding this comment

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

Looks good! Really liked how organized and clean the code was. I was able to add an item, check the item, and dataNextPurchased was saved to the next day in Firebase.

I was also able to mess around with the dates in Firebase (while also manually incrementing totalPurchases), and was able to see varying dates saved in dateNextPurchased based off what was saved to dateLastPurchased.

Comment on lines 31 to 33
updateItem(listPath, id, {
...item,
})
Copy link
Member

Choose a reason for hiding this comment

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

nitpick ( non-blocking ): You can just pass in the item here now:

Suggested change
updateItem(listPath, id, {
...item,
})
updateItem(listPath, id, item)

Comment on lines 102 to 103
// We'll use the user's email as the document id
// We'll use the user's emailƒ as the document id
Copy link
Member

Choose a reason for hiding this comment

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

praise (non-blocking): Always love typo cleanups!

console.error('Error updating item: ', error);
});
console;
Copy link
Member

Choose a reason for hiding this comment

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

nitpick ( non-blocking | if-minor ): Should probably cleanup this stray console :)

Suggested change
console;

Comment on lines 1 to 2
// import { calculateEstimate } from '@the-collab-lab/shopping-list-utils';

Copy link
Member

Choose a reason for hiding this comment

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

nitpick ( non-blocking): And stray comment here

Suggested change
// import { calculateEstimate } from '@the-collab-lab/shopping-list-utils';

Copy link
Member

@mindyzwan mindyzwan left a comment

Choose a reason for hiding this comment

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

You made it through time land! 🎉 Way to persist!

the-persistence-of-memory

@arandel1 arandel1 merged commit ee33a0d into main Sep 16, 2024
2 checks passed
@arandel1 arandel1 deleted the eb-ar-estimate-next-purchase-date-issue-11 branch September 16, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants