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

Added check for similar items using regex. #27

Merged
merged 5 commits into from
Sep 17, 2024

Conversation

MarcosPerez16
Copy link
Collaborator

Description

-First we passed in data as props to the ManageList component. After that we were able to use the data object to filter and grab items that matched a users input.
-Then we passed in a regex expression into the .replace method to check both spacing and characters in the data and users input. We used toLowerCase() to check for matching letters regardless of case.
-We filtered through the list to find any matches, and if the filtered list was > 0 users were alerted that the item exists and addItem would not execute.

Related Issue

closes #10

Acceptance Criteria

  • Show an error message if the user tries to submit an empty item
  • Show an error message if the user tries to submit a new item that is identical to an existing name. For instance, if the list contains apples and the user adds apples.
  • Show an error message if the user tries to submit a new item that matches an existing name with punctuation and casing normalized. For instance, if the list contains apples and the user adds aPples or apples, or a pples.
  • The user’s original input is saved in the database

Type of Changes

-enhancement

Updates

-Alert with a pop-up if a similar item exists.

Testing Steps / QA Criteria

  1. Add new item that already exists on your list
  2. Alert will pop-up saying item already exists and in firebase dateCreated should not update.
  3. Test for spaces in between and characters: aPples or apples, or a pples.

Copy link

github-actions bot commented Sep 12, 2024

Visit the preview URL for this PR (updated for commit 9edd71e):

https://tcl-76-smart-shopping-list--pr27-mp-sm-check-for-exis-0yfpi088.web.app

(expires Mon, 23 Sep 2024 21:56:16 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 512b1a88be8ae05fd3e727b99332819df760271d

@arandel1
Copy link
Collaborator

nit-pick / non-blocking: From a UX perspective, I think the alert message could be cleaner: maybe just "a similar item is already on your list" or "A similar item is already on your list: Do you still want to add "bagel"?" The second suggestion requires another confirmation.

@arandel1
Copy link
Collaborator

nit-pick / non-blocking: I had "bagels" on my list, and was able to add "bagel".

Copy link
Collaborator

@EmmaBin EmmaBin left a comment

Choose a reason for hiding this comment

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

I love the implementation of regex! Just to add to what Allison is suggesting, if I already have 'apple' in the list, ' Applessss' can still be added to the list.
Screenshot 2024-09-14 at 11 49 03 AM

@sar-mko
Copy link
Collaborator

sar-mko commented Sep 14, 2024

nit-pick / non-blocking: From a UX perspective, I think the alert message could be cleaner: maybe just "a similar item is already on your list" or "A similar item is already on your list: Do you still want to add "bagel"?" The second suggestion requires another confirmation.

This could be cool! I think this could be a good option having a second suggestion. Could make it easier to do this for now before a check for plural strings.

Copy link
Collaborator

@arandel1 arandel1 left a comment

Choose a reason for hiding this comment

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

Nice! The UX message looks great. I was still able to add "bagel" and "agel" when I already had "bagels" on my list.
Screen Shot 2024-09-14 at 11 24 14 PM

Copy link
Collaborator

@mentalcaries mentalcaries 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 so far. I do like the prompt that warns about similar items and leaves it to the user if to add it.
Perhaps for the case of an exact match you can alert the user that the item is already on the list?

Also I had the same issue as @arandel1 in that if a plural version of an item existed, the app would still lit me add a singular form

src/App.jsx Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
src/views/ManageList.jsx Outdated Show resolved Hide resolved
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.

Looks great, well done! 🎉

@sar-mko sar-mko merged commit 2907fc7 into main Sep 17, 2024
2 checks passed
@sar-mko sar-mko deleted the mp-sm-check-for-existing-and-empty-items branch October 4, 2024 19:29
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.

10. As a user, I want to be alerted when I’m entering an empty item or an item that's already on my list
6 participants