Skip to content

Commit

Permalink
fix: Add validation for empty search text in Playground component
Browse files Browse the repository at this point in the history
  • Loading branch information
HasanYahya101 committed Jun 4, 2024
1 parent 1624de6 commit 422222a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 239 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/components/component/playground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ export function Playground() {
}

const searchClicked = () => {
if (search === "") {
toast.error("Please enter search text", {
action: {
label: "Close",
onClick: () => {
toast.dismiss();
}
},
})
return;
}

const searchResults = text.match(new RegExp(search, "gi"));
if (searchResults) {
toast.success(`${searchResults.length} matches found`, {
Expand All @@ -95,6 +107,7 @@ export function Playground() {
})
setSearchResults([]);
}
console.log(searchResults);
}

return (
Expand Down
238 changes: 0 additions & 238 deletions src/components/component/words.jsx

This file was deleted.

0 comments on commit 422222a

Please sign in to comment.