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

manage shopping list by adding new item #21

Merged
merged 8 commits into from
Aug 25, 2024
Merged

Conversation

EmmaBin
Copy link
Collaborator

@EmmaBin EmmaBin commented Aug 20, 2024

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

Description

We updated the manageList component by adding a form to take the user's input, a user can add the name of the item and select one of the three options. When the form is submitted, the use can see a message displayed.

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

After

Screenshot 2024-08-20 at 10 47 17 AM

Testing Steps / QA Criteria

Copy link

github-actions bot commented Aug 20, 2024

Visit the preview URL for this PR (updated for commit 5a1d721):

https://tcl-76-smart-shopping-list--pr21-ar-eb-add-new-item-i-n8xipbvg.web.app

(expires Sun, 01 Sep 2024 16:11:37 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 512b1a88be8ae05fd3e727b99332819df760271d

Copy link
Collaborator

@MarcosPerez16 MarcosPerez16 left a comment

Choose a reason for hiding this comment

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

Looks good!

<button type="submit">Submit</button>
</form>
{formSubmitted && <div>{formData.name} is added to your list</div>}
</div>
Copy link
Collaborator

@mentalcaries mentalcaries Aug 22, 2024

Choose a reason for hiding this comment

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

bug the success message works when an item is added, however the message doesn't clear. If I submit an item, and then start submitting a second item, the success message just gets updated with the new item name

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

praise (non-blocking): I like how an alert is used for showing the message here! And I see it was used to solve this bug, great idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mentalcaries Thank you for catching this bug and the issue we overlooked with implementing addItem.

@mentalcaries
Copy link
Collaborator

@EmmaBin @arandel1 good work so far, but the form data isn't being submitted to Firebase just yet. You'll need to invoke the addItem function in firebase.js. Please also log into Firebase and confirm whether the new items have been submitted to the test-list
image

Copy link
Collaborator

@sar-mko sar-mko left a comment

Choose a reason for hiding this comment

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

Looks good!

<button type="submit">Submit</button>
</form>
{formSubmitted && <div>{formData.name} is added to your list</div>}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

praise (non-blocking): I like how an alert is used for showing the message here! And I see it was used to solve this bug, great idea.

src/views/Home.jsx Outdated Show resolved Hide resolved
src/api/firebase.js Outdated Show resolved Hide resolved
src/views/Home.jsx Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
Comment on lines +36 to +51
addItem(listPath, {
itemName: formData.name,
daysUntilNextPurchase: parseInt(formData.frequency),
})
.then(() => {
window.alert(`${formData.name} has been added to your list.`);
setFormData({
name: '',
frequency: '',
});
})
.catch((error) => {
window.alert(`${formData.name} failed to add to your list.`);
console.error('Error:', error);
});
}
Copy link
Member

Choose a reason for hiding this comment

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

note (non-blocking): This does read very cleanly! I like that you considered that in your usage here. And it does work well here, but it may be worthwhile to know that it's not an exact swap for using async/await see here for a document on it!

Copy link
Member

@mindyzwan mindyzwan left a comment

Choose a reason for hiding this comment

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

Well done! 👏 Nothing blocking, feel free to merge!

@EmmaBin EmmaBin merged commit d4bdc8e into main Aug 25, 2024
2 checks passed
@mentalcaries mentalcaries deleted the ar-eb-add-new-item-issue-5 branch August 30, 2024 00:08
@sar-mko sar-mko mentioned this pull request Sep 24, 2024
3 tasks
sar-mko added a commit that referenced this pull request Sep 28, 2024
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
6 participants