Skip to content

Commit

Permalink
Merge branch 'dg-sm-calculate-next-date' of https://github.com/the-co…
Browse files Browse the repository at this point in the history
…llab-lab/tcl-68-smart-shopping-list into dg-sm-calculate-next-date
  • Loading branch information
DevinaG007 committed Mar 10, 2024
2 parents e33a6be + 1cfcd3b commit d721a14
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/api/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ export async function addItem(listPath, { itemName, daysUntilNextPurchase }) {
name: itemName,
totalPurchases: 0,
});
console.log(newItem);
return newItem;
}

Expand All @@ -206,10 +205,10 @@ async function handleCalculateEstimate(listRef) {
lastPurchased,
selectedItem.data().dateNextPurchased.toDate(),
);
let daysSincePrevPurchase = getDaysBetweenDates(lastPurchased, new Date());
const daysSincePrevPurchase = getDaysBetweenDates(lastPurchased, new Date());

//calculates a new estimate based on the previous estimate, days since last purchased, and total purchases
let newEstimate = calculateEstimate(
const newEstimate = calculateEstimate(
previousEstimate,
daysSincePrevPurchase,
selectedItem.data().totalPurchases,
Expand All @@ -221,7 +220,7 @@ async function handleCalculateEstimate(listRef) {
export async function updateItem(listPath, itemID, isChecked) {
const listRef = doc(db, listPath, 'items', itemID);

let { newEstimate, selectedLastPurchase } =
const { newEstimate, selectedLastPurchase } =
await handleCalculateEstimate(listRef);

//checks to see if checkbox is checked in front end, updates selected item
Expand Down

0 comments on commit d721a14

Please sign in to comment.