EiSimp / Book-Archive

BookPals
https://book-archive-production.up.railway.app/homepage
0 stars 0 forks source link

Search Functionality with Pagination and Error Handling #59

Closed elllaPark closed 3 months ago

elllaPark commented 3 months ago

Issue

The application lacked a robust search functionality to allow users to search for books.

Related Issue: Closes #41

Changes

Search Functionality

Files Modified: ArchiveController.java Added logic in the getSearchResult() method to handle search queries and pagination. Added logic to trim and validate search queries. Encoded the search query and made a request to the Google Books API. Processed the API response to extract book details and manage pagination. Handled errors by setting appropriate messages in the model.

Book Data Transfer Object

Files Created: BookDTO.java Added fields for book details like title, ID, average rating, and thumbnail. Created getter and setter methods for these fields to encapsulate the book data.

Thymeleaf Template Updates

Files Modified: searchresult.html, bookcard.html, homepage.html Updated the template to display search results and messages. Implemented pagination controls and logic to handle multiple pages of results. Added a message display for empty or invalid search queries. Commented out the book card display on the homepage

JavaScript Enhancements

Files Modified: search.js Enhanced the script to manage search queries and pagination links. Added validation to alert users when they enter an empty search query.

Style Modification

Files Modified: card.css, style.css Modified attributes for better UI. Added CSS attributes for the pagination in the style.css.