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

creating a new shopping list #20

Merged
merged 5 commits into from
Aug 24, 2024
Merged

creating a new shopping list #20

merged 5 commits into from
Aug 24, 2024

Conversation

didemydn
Copy link
Collaborator

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

Description

A shopping list is a set of items associated with the owner's unique id and the name of the shopping list. Users need to be able to create new shopping lists. To do this, the Home view should present them with a form that allows them to enter the name of their list. Additionally, we need to do a few things to create that list:

Related Issue

issue #4

Acceptance Criteria

UI-related tasks:

  • The Home view displays a form that allows users to enter the name of a shopping list and then create a list with that name.
  • 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 list either was or was not created and saved to the database.

Data-related tasks:

  • Clicking the button uses the createList function in src/api/firebase.js to create a new shopping list for the user.
  • The shopping list path is stored in local storage using the setListPath function.
  • Once the list has been created and saved, the user is redirected to the List view.

Updates

Before

Home view, there is no list label and create a list button.
image

After

creating list button and form
image

after writing a list name you should navigate to list view
image

Home view after creating a list
image

Testing Steps / QA Criteria

  • npm start
  • fill the form to create a list on the home view

Copy link

Visit the preview URL for this PR (updated for commit 927c189):

https://tcl-78-smart-shopping-list--pr20-dc-tc-new-shopping-l-rsv86j0c.web.app

(expires Thu, 29 Aug 2024 15:29:06 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c781903507c1507075d7a974036959ddeec29c0a

Copy link
Collaborator

@GrannyYetta GrannyYetta left a comment

Choose a reason for hiding this comment

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

The feature works as expected, thank you for the comments in the code.

We had the idea that later on we can implement toast notifications to display the messages. Given the redirection to the /list view, the messages are not visibly displayed.

Looking forward to the code review!

Copy link
Collaborator

@eva-lng eva-lng left a comment

Choose a reason for hiding this comment

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

The feature for creating new lists works well, code is looks good and is easy to understand. As GrannyYetta mentionted in the comments, in the future we could implement toaster for all notifications. Right now the user doesn't see any success message because they are redirected to the List view right after submitting the form.

Copy link
Collaborator

@Amaka202 Amaka202 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 team. Your feature works well. 💥💥

Something to consider if you have the time now or later during styling/refactoring (last 2 weeks) is adding a timer to show the success or error message before redirecting the users to the list page. Cause now I dont get to see the success message after adding, it just takes me to list page. But if a timer is in place I will see it before it redirects.

The timer will also help for the error message too cause now if I get an error it never goes away whereas if there was a timer the error message will show for like 5 seconds and then clear by itself.

Comment on lines +12 to +31
const handleCreateListButton = async (e) => {
e.preventDefault();
if (!listName) {
setMessage('Enter a list name');
return;
}

try {
await createList(userId, userEmail, listName);
setMessage('New list successfully created');

const createListPath = `${userId}/${listName}}`;
setListPath(createListPath);
navigate('/list'); //redirect to the list view
} catch (error) {
//Logging and error messages if list is not created
console.error('error creating a list', error);
setMessage('Failed to create list. Please try again!');
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good job on this function team! it is a pleasant way to handle async calls!

@didemydn didemydn merged commit 5197a57 into main Aug 24, 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 participants