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

Add item to firestore #20

Merged
merged 10 commits into from
Aug 25, 2024
Merged

Add item to firestore #20

merged 10 commits into from
Aug 25, 2024

Conversation

marshjaja
Copy link
Collaborator

Description

New feature: Add new item to list by saving it to Firestore.
Used a single useState for the form data.

Related Issue

Closes #5

Acceptance Criteria

UI-related tasks:

  • The 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:
    • “Soon”, corresponding to 7 days
    • “Kind of soon”, corresponding to 14 days
    • “Not soon”, corresponding to 30 days
  • The input that accepts the name of the item has a semantic label element associated with it
  • The user can submit this form with both the mouse and the Enter key
  • When the user submits the form, they see a message indicating that the item either was or was not saved to the database.
    Data-related tasks:
  • The console.log in the addItem function in src/api/firebase.js is replaced with a function that adds the new document to the Firestore database. That function will be imported from the firebase/firestore module.
  • The user’s soon/not soon/kind of soon choice is used to calculate nextPurchasedDate

Type of Changes

feature

Updates

Before

image
image (1)

After

Screenshot 2024-08-21 at 15 34 30
Screenshot 2024-08-21 at 15 34 52

Testing Steps / QA Criteria

  • Do a git pull and git checkout mm-jo-rendered-list.
  • Open the homepage by running npm start.
  • Navigate to ManageList.
  • Complete the form to add a new item.
  • Submit using enter or clicking Add Item button.
  • You should see a success message.
  • Navigate to List to see the added item.

Copy link

github-actions bot commented Aug 21, 2024

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

https://tcl-79-smart-shopping-list--pr20-mm-qg-feat-additem-o0v3zun6.web.app

(expires Sat, 31 Aug 2024 11:25:34 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: d91d9ddbda780208241c52942f544acf8e81407a

Copy link
Collaborator

@Hudamabkhoot Hudamabkhoot left a comment

Choose a reason for hiding this comment

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

The only thing I would suggest is removing the console.log statements other than that well done! 👏

@joriordan332
Copy link
Collaborator

Looks great guys! Well done 😃

@marshjaja marshjaja requested a review from redapy August 23, 2024 11:10
@joriordan332 joriordan332 requested review from Hudamabkhoot and removed request for Hudamabkhoot August 24, 2024 09:20
Copy link
Collaborator

@redapy redapy left a comment

Choose a reason for hiding this comment

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

everything works as expected, great work team! I left only a small note

Comment on lines 166 to 169
// TODO: Replace this call to console.log with the appropriate
// Firebase function, so this information is sent to your database!
return console.log(listCollectionRef, {
const newItemEntry = doc(listCollectionRef);
return setDoc(newItemEntry, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

because we are not trying to update items here, it would be better to use the addDoc function instead of setDoc. (it takes the listCollectionRef directly, you won't need const newItemEntry = doc(listCollectionRef);)

Also, you can remove these comments as you already replaced console.log

…dating existing items

- Delete comments referring to previous console.log usage
@marshjaja marshjaja merged commit 00fe4a9 into main Aug 25, 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
Development

Successfully merging this pull request may close these issues.

5. As a user, I want to add a new item to my shopping list so I can start recording purchases
5 participants