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

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

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

hun-ah
Copy link
Collaborator

@hun-ah hun-ah commented Feb 13, 2024

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 the itemValue state.

Upon submission of the form, the addItem function from firebase.js will run, which takes in two parameters: the listPath prop (passed down from App.jsx into ManageList.jsx and finally into AddItem.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 the addItem function to use the setDoc method from firebase to create a new document and save to the database.

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

Enhancement

Updates

Before

Screenshot 2024-02-12 at 7 17 34 PM

After

Screenshot 2024-02-12 at 7 17 46 PM

Testing Steps / QA Criteria

  1. run npm start
  2. on the / or "home" route, make sure to click the list displayed to set the listPath
  3. navigate to the Manage List page using the navigation
  4. enter an item name, select a timeframe and click the add item button
  5. navigate to the List page using the navigation to see the newly added item

eonflower and others added 3 commits February 12, 2024 11:37
…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
@hun-ah hun-ah added the enhancement New feature or request label Feb 13, 2024
@hun-ah hun-ah requested review from 3campos and StefieCaff February 13, 2024 00:36
Copy link

github-actions bot commented Feb 13, 2024

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

Copy link
Collaborator

@StefieCaff StefieCaff left a 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.

src/components/AddItem.jsx Show resolved Hide resolved
Copy link
Collaborator

@StefieCaff StefieCaff left a comment

Choose a reason for hiding this comment

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

nice catch!

Copy link
Collaborator

@3campos 3campos left a 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.

@eonflower eonflower requested a review from deeheber February 13, 2024 19:10
@hun-ah
Copy link
Collaborator Author

hun-ah commented Feb 13, 2024

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 dateNextPurchased though - it's probably a reference to that.

@3campos
Copy link
Collaborator

3campos commented Feb 13, 2024

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 dateNextPurchased though - it's probably a reference to that.

Agreed!

Copy link
Member

@deeheber deeheber left a 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. 🚀

@hun-ah hun-ah merged commit 7f12766 into main Feb 13, 2024
2 checks passed
@hun-ah hun-ah deleted the an-hm-issue-5 branch February 13, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
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