Closed NickRoccodev11 closed 1 month ago
Visit the preview URL for this PR (updated for commit 3a52628):
https://tcl-74-smart-shopping-list--pr29-sd-nr-11-c1v1e3jx.web.app
(expires Fri, 20 Sep 2024 05:05:46 GMT)
🔥 via Firebase Hosting GitHub Action 🌎
Sign: 79d73546692f99aad8468c28e36db434e2c190ac
@shuveksha-tuladhar Thanks for the video explanation! so yes, for now that is the expected behavior. the calculateEstimate
function first checks the total number of purchases an item has. if it has been purchased less than twice, the function returns daysSinceLastPurchase
. (or "daysSinceLastTransaction" as it's labeled in the documentation linked above) What this means is, if you create an item and buy it on the same day, 0 days have passed since the item was last interacted with, so it sets the interval to 0. This might not be the behavior we ultimately want (considering adding an item to the list isn't technically purchasing it) but it is what we expect at this point
Description
This ticket creates an estimate for the next purchase date of an item.
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
Updates
Before
After
Testing Steps / QA Criteria
dateNextPurchased
date.List
view.dateNextPurchased
has changed to a future date.