Closed apdsrocha closed 3 years ago
Visit the preview URL for this PR (updated for commit 22b5cc4):
https://tcl-23-shopping-list--pr22-jc-ar-mark-items-pur-jmjj22gz.web.app
(expires Sun, 09 May 2021 17:19:22 GMT)
🔥 via Firebase Hosting GitHub Action 🌎
Ready for merge approval!
Description
This PR updates the List view which was previously displaying the information straight from the JSON file. The list items are now showing individual list items with a checkbox that can be used to mark purchased items.
Related Issue
closes #9
Acceptance Criteria
Type of Changes
Updates
Before
https://user-images.githubusercontent.com/47455758/116334400-c2cdc700-a79a-11eb-8571-0fd94d637b0f.mp4
After
https://user-images.githubusercontent.com/47455758/116334417-ca8d6b80-a79a-11eb-8208-274f98e64c55.mp4
Testing Steps / QA Criteria
git checkout jc-ar-mark-items-purchased
npm install
npm start
sire agnew dutch
Notes
defaultChecked
property for an<input type="checkbox" />
is so simple and elegant!compareTimeStamps(lastPurchased)
that we call inside thedefaultChecked
property. We pass in thedoc.data().last_purchased
tocompareTimeStamps(lastPurchased)
and that checks if the.last_purchased
property is less than 24 hours (or 86,400,00 milliseconds) from the current moment the List.js component mounts,const currentElapsedMilliseconds = Date.now()
. This returns to us atrue
orfalse
boolean that dictates whether the checkbox is checked or not, even on page reload.Updates
last_purchased: null
back to Firestore when an item is unchecked. We will have decisions to make in a later story, issue 10, where we decide how to keep track of multiple timestamps to be able to compare and calculate average purchase frequency.That said, I removed lines 16-19: