-
Notifications
You must be signed in to change notification settings - Fork 2
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
5. As a user, I want to add a new item to my shopping list so I can start recording purchases #23
Conversation
…mported AddItem component; created AddItem component, including state and associated functions; changed console log to setDoc function in firebase.js
…Item in firebase.js and passed to setDoc function
Visit the preview URL for this PR (updated for commit 2c025c2): https://tcl-66-smart-shopping-list--pr23-an-hm-issue-5-xlmo5and.web.app (expires Tue, 20 Feb 2024 12:50:47 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2dc16cb2a79cbd6723fdc511b73e0743df1d18d0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, everything is working well for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having reviewed your code and tested it, I approve merging these changes! The code is well written and everything works as expected. I used a console log to confirm that the state variable, daysUntilNextPurchase, was reflecting the option (7, 14, or 30 days) selected by the user. Nice job!
As an aside, we don't have a "nextPurchasedDate" variable in the app, so I assume that is a typo in the instructions that we were provided for this issue.
You're right, there is a |
Agreed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to merge to me. 🚀
Description
This PR allows a user to add a new item to their list and to select the next time they think they will purchase said item.
We have created a new component called
AddItem.jsx
, which contains a form with a text and select input. These inputs will keep track of the users changes and set them into theitemValue
state.Upon submission of the form, the
addItem
function fromfirebase.js
will run, which takes in two parameters: the listPath prop (passed down fromApp.jsx
intoManageList.jsx
and finally intoAddItem.jsx
) and the itemValue state (an object containing the item name as a string and the daysUntilNextPurchase as a number). Upon form submission, the user will be alerted if the item was successfully added to the database or not.In the
firebase.js
file, we have updated theaddItem
function to use thesetDoc
method from firebase to create a new document and save to the database.Related Issue
closes #5
Acceptance Criteria
UI-related tasks:
ManageList
view displays a form that allows them to enter the name of the item and select how soon they anticipate needing to buy it again. There should be 3 choices for this:label
element associated with itEnter
keyData-related tasks:
console.log
in theaddItem
function insrc/api/firebase.js
is replaced with a function that adds the new document to the Firestore database. That function will be imported from thefirebase/firestore
module.nextPurchasedDate
Type of Changes
Enhancement
Updates
Before
After
Testing Steps / QA Criteria