Ура, все работаетgit add .git add . НАЧИНАЕТСЯ НОВАЯ ЭРА

This commit is contained in:
2025-09-25 09:41:23 +04:00
parent e378591189
commit f347eb098b
2 changed files with 19 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ function Search() {
const fetchBooks = async () => {
try {
setLoading(true);
const response = await bookAPI.getAll();
const response = await bookAPI.getAll({ size: 100 });
setBooks(response.data.content);
} catch (error) {
setError(error.message);
@@ -26,6 +26,16 @@ function Search() {
};
fetchBooks();
}, []);
const eventPressEnter = (event) => {
if (event.key === "Enter") {
const value = event.target.value;
if (!books.includes(value)) {
console.log("Нет такой книги");
return;
}
console.log(event.target.value)
}
};
if (loading) return <div> Загрузка</div>;
if (error) return <div> Ошибка: {error}</div>;
return (
@@ -36,7 +46,13 @@ function Search() {
freeSolo
options={books.map((book) => book.title)}
className="form-control form-control-lg"
renderInput={(params) => <TextField {...params} label="Поиск книг" />}
renderInput={(params) => (
<TextField
{...params}
label="Поиск книг"
onKeyDown={eventPressEnter}
/>
)}
/>
</div>
<div className="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">

View File

@@ -105,7 +105,7 @@ function Headers() {
<li>
<HashLink
className="dropdown-item"
to="/choice"
to={`/choice#${genre}`}
key={index}
>
{genre}