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

Rt el estimate next purchase #26

Merged
merged 13 commits into from
Sep 13, 2024
Merged

Conversation

GrannyYetta
Copy link
Collaborator

Type
New Feature
the app calculates the next purchase date of an item when checked

Description

When the item in a list is checked (i.e. purchased), the firebase.js updates the item's dateNextPurchased property. In the updateItem function, the calculateEstimate function is used to calculate the date of the next purchase.

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

New Feature

Updates

There are no UI changes.

Testing Steps / QA Criteria

  1. npm start
  2. Start app in the browser.
  3. Navigate to ManageList view
  4. Add an item to a list
  5. Navigate to the Firebase console and check the newly-created item's dateNextPurchased
  6. Go back to the browser and check the item as purchased in the List view
  7. Corroborate the updated item in the Firebase console. The dateNextPurchased in the document should be updated based on the time elapsed between the item's creation and it's purchase. If the item is checked as purchased shortly after its addition to the list, the time difference will be minimal.

Copy link

github-actions bot commented Sep 11, 2024

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

https://tcl-78-smart-shopping-list--pr26-rt-el-estimate-next-5tohuxv1.web.app

(expires Thu, 19 Sep 2024 16:20:56 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c781903507c1507075d7a974036959ddeec29c0a

Copy link
Contributor

@tataw-cl tataw-cl left a comment

Choose a reason for hiding this comment

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

Works perfectly 😁👌🏾

@tataw-cl
Copy link
Contributor

tataw-cl commented Sep 11, 2024

And I'm so glad you guys also removed those redundant console.log statements too 😅

@didemydn
Copy link
Collaborator

Hi Eva and Becka, It is working well. Thank you

@eva-lng eva-lng requested a review from vivitt September 12, 2024 12:39
Copy link
Collaborator

@vivitt vivitt left a comment

Choose a reason for hiding this comment

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

Thanks for your work team :) I am happy to see this feature is almost complete ✨
You did a nice job creating the functions in dates.js and in updateItem in firebase.js.

I left a few comments, please reach out if you have any questions or need any clarifications.

@@ -1,3 +1,5 @@
import { Timestamp } from 'firebase/firestore';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This import can be deleted since not being used

* @returns {number}
*/
export function getDaysBetweenDates(lastDate, nextDate) {
// const lastDateInMS = lastPurchase.toDate().getTime();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we delete those lines?

itemId,
{ dateLastPurchased, totalPurchases },
) {
export async function updateItem(listPath, itemId, { totalPurchases }) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I discovered when I create an item and mark it as purchased, the dateNextPurchased is updated to the current date:
Screenshot 2024-09-12 at 09 13 40

I think this is weird bc we are rolling back the dateNextPurchase, and I believe this shouldn't be happening.
This is the item date when it was first created, before being marked as purchased:
Screenshot 2024-09-12 at 09 13 24
What do you think?

Copy link
Collaborator

@vivitt vivitt left a comment

Choose a reason for hiding this comment

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

Nice job ⚡️

@GrannyYetta GrannyYetta merged commit 3958b50 into main Sep 13, 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
5 participants