diff --git a/data.py b/data.py index 98ff870..46166c7 100644 --- a/data.py +++ b/data.py @@ -3,7 +3,7 @@ from typing import Optional # Конфигурация USERNAME = "admin" -PASSWORD = "n_ElBL9LTfTTgZSqHShqOg" +PASSWORD = "TzUlDpUCHutFa-oGCd1cBw" BASE_URL = "http://localhost:8000" diff --git a/library_service/static/books.js b/library_service/static/books.js index b9bd30f..bf33c32 100644 --- a/library_service/static/books.js +++ b/library_service/static/books.js @@ -5,6 +5,11 @@ $(document).ready(() => { let pageSize = 20; let totalBooks = 0; + const urlParams = new URLSearchParams(window.location.search); + const genreIdsFromUrl = urlParams.getAll("genre_id"); + const authorIdsFromUrl = urlParams.getAll("author_id"); + const searchFromUrl = urlParams.get("q"); + Promise.all([ fetch("/api/authors").then((response) => response.json()), fetch("/api/genres").then((response) => response.json()), @@ -18,15 +23,25 @@ $(document).ready(() => { .attr("data-name", author.name) .text(author.name) .appendTo($dropdown); + + if (authorIdsFromUrl.includes(String(author.id))) { + selectedAuthors.set(author.id, author.name); + } }); const $list = $("#genres-list"); genresData.genres.forEach((genre) => { + const isChecked = genreIdsFromUrl.includes(String(genre.id)); + + if (isChecked) { + selectedGenres.set(genre.id, genre.name); + } + $("