Skip to content

Commit

Permalink
notify searchbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariaky committed Mar 9, 2024
1 parent e196ed4 commit d9e48b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Searchbar/Searchbar.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Form, Input, Button } from './SearchBar.styled';
import { Notify } from 'notiflix/build/notiflix-notify-aio';

const Searchbar = ({ setSearchParams, fetchMoviesFromApi }) => {
const handleSubmit = async e => {
e.preventDefault();
const searchForm = e.currentTarget;
const searchQuery = searchForm.elements.query.value;

if (!searchQuery.trim()) {
Notify.warning('Please enter a movie name.');
return;
}

setSearchParams({ query: searchQuery });
searchForm.reset();
fetchMoviesFromApi(searchQuery);
Expand Down

0 comments on commit d9e48b1

Please sign in to comment.