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

Feat: Allowing user to add items to shopping list #22

Merged
merged 21 commits into from
Aug 25, 2024

Conversation

bbland1
Copy link
Collaborator

@bbland1 bbland1 commented Aug 19, 2024

For an example of how to fill this template out, see this Pull Request.

Description

This code added the ability for the user add an item to their list. A form was added to the manage list page of the app that has a text input and 3 radio options that are required to submit the form. The listPath prop of the app.js was passed to the manage list component to properly pass the information to the component and allow the required information for the add item call of 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

Screen.Recording.2024-08-22.at.1.56.13.AM.mov

After

Screen.Recording.2024-08-22.at.3.10.09.AM.mov

Testing Steps / QA Criteria

  • From your terminal, pull down this branch with git pull origin bb-rc-add-items-to-list and check that branch out with git checkout bb-rc-add-items-to-list
  • Then npm ci to install the newly added dependencies locally and npm start to launch the app.
  • If still signed in from previous usage of the app, make sure to sign out and sign back in.
  • Navigate to the Manage List page.
  • Enter an item name and select an option for when to buy, and click submit.
  • Enter another item, hit tab to go to the went to buy, using arrows to select which option, hit spacebar to select and enter to submit.
  • With both version there should be a toast at top showing pending and success or fail.
  • Navigate back to the list and see your newly added items!

Copy link

github-actions bot commented Aug 19, 2024

Visit the preview URL for this PR (updated for commit 1792e84):

https://tcl-77-smart-shopping-list--pr22-bb-rc-add-items-to-l-6oy33ckf.web.app

(expires Sun, 01 Sep 2024 16:57:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b77df24030dca7d8b6561cb24957d2273c5e9d72

@bbland1 bbland1 changed the title adding a form layout to manage list Feat: Allowing user to add items to shopping list Aug 19, 2024
Co-authored-by: Ross Clettenberg <[email protected]>
@bbland1 bbland1 added the enhancement New feature or request label Aug 19, 2024
@RossaMania
Copy link
Collaborator

Yay! It was great pair programming yesterday! The next step is passing that props object from managelist to firebase!!!

src/api/firebase.js Outdated Show resolved Hide resolved
@RossaMania
Copy link
Collaborator

RossaMania commented Aug 20, 2024 via email

@RossaMania
Copy link
Collaborator

Confirmed in a chat: we don't need any special React Forms libraries or hooks. What we have is fine. If we do anything special, it'll come back to haunt all of us later. My words.

src/views/ManageList.jsx Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
@tannaurus
Copy link
Collaborator

Left behind some thoughts, but this LGTM! 🚀 Great work!

bbland1 and others added 4 commits August 23, 2024 13:01
…election, removing redundant console logs, and fixing single quotes in ManageList.jsx

Co-authored-by: Brianna <[email protected]>
…s key value pairs. This way the variable numbers can be changed at the top in the purchaseTimelines object.

Co-authored-by: Brianna <[email protected]>
@RossaMania
Copy link
Collaborator

Thanks everybody for the sweet feedback! This is so cool! We were able to remove redundant console logs, use key-value pairs in an object for a "purchaseTimeline". We were also able to apply some aria-labels! We tried to change single quotes to double quotes, but it kept reverting to single quotes on some! :D

src/views/ManageList.jsx Outdated Show resolved Hide resolved
src/api/firebase.js Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
@tannaurus tannaurus mentioned this pull request Aug 24, 2024
7 tasks
Copy link
Collaborator

@eternalmaha eternalmaha left a comment

Choose a reason for hiding this comment

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

The code is so well structured and readable! I saw some really great suggestions that take future implementations into account! Possible interesting take could also have been to dynamically render the input elements through mapping a revised purchaseTimeLines object! In this case, there's only three options, so it's not necessary at all but if the project expanded, it could be a useful code revision to increase scalability and reduce lines of code!

Copy link
Collaborator Author

@bbland1 bbland1 left a comment

Choose a reason for hiding this comment

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

The code is so well structured and readable! I saw some really great suggestions that take future implementations into account! Possible interesting take could also have been to dynamically render the input elements through mapping a revised purchaseTimeLines object! In this case, there's only three options, so it's not necessary at all but if the project expanded, it could be a useful code revision to increase scalability and reduce lines of code!

I think this is something I would definetly like to look at trying in a refactor or revision, like you mention I think it would bring some good things to the code! One of Tanner's comments made me think about doing an array as well! I know it isn't neccary for this PR and maybe not for the project but I'd like to give it a try maybe on a later week because at this moment I'm not sure how to do the refactor for it but I think it would be really nice to get the radio button into a component and use the array to may over and dynamically make them.

Copy link
Collaborator

@alex-andria alex-andria left a comment

Choose a reason for hiding this comment

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

Nice job Brianna and Ross, I know this one was a deeper introduction to firebase as well for you two. The form functions amazing and love seeing you utilize react-hot-toast to fit the alert needs of your form. One thing we may want to consider in the future is the case in which the form submission doesn't work / the addItem call fails. In the image below is what I see when I test with turning off my wifi (such a in an event a user's wifi goes out) and hitting submit for the new item. There the notification pop-up stalls. Just some things to consider later on if you wanted to tackle that use case. Still great work!

image

package.json Show resolved Hide resolved
src/views/ManageList.jsx Show resolved Hide resolved
@bbland1 bbland1 merged commit 8aa6847 into main Aug 25, 2024
2 checks passed
@bbland1 bbland1 deleted the bb-rc-add-items-to-list branch August 25, 2024 16:59
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
7 participants