Overview
The Book Catalog feature provides users with an interactive interface to browse available books in the virtual library. Users can view book details including cover images, authors, genres, publication years, and availability status. The catalog also enables users to submit loan requests directly from the interface.The catalog automatically displays real-time availability status. Only available books can be requested for loans.
Component Architecture
The catalog is implemented in theCatalogoComponent located at:
- TypeScript:
src/app/features/catalogo/catalogo.ts:14 - Template:
src/app/features/catalogo/catalogo.html
Key Dependencies
User Workflow
View Catalog
Navigate to the catalog page to see all books displayed in a responsive card grid layout
Browse Books
Review book information including title, authors, genre, publication year, and cover image
Check Availability
Each book displays a badge indicating “Disponible” (Available) or “Agotado” (Out of Stock)
Core Functionality
Loading Books
The component loads all books on initialization using theLibroService:
catalogo.ts:21-36
Loan Request Submission
Users can request loans for available books with built-in confirmation:catalogo.ts:38-56
Loan requests are sent to the backend endpoint
/prestamos/solicitar/{libroId} and require admin approval before being granted.UI Components
Book Card Layout
Each book is displayed in a Bootstrap card with:- Cover Image: Displays book cover or a default book icon (📘) if no image is available
- Genre Badge: Color-coded badge showing the book’s genre
- Availability Badge: Green for “Disponible”, red for “Agotado”
- Title: Bold heading with the book title
- Authors: Comma-separated list of author names
- Publication Year: Year of publication or “N/A”
- Action Button: Enabled for available books, disabled for out-of-stock items
Responsive Grid
The catalog uses a responsive Bootstrap grid:catalogo.html:10-71
Loading State
A spinner displays while books are being fetched:catalogo.html:4-8
API Integration
GET /libros
Fetches all books in the library with their associated authors, genres, and availability status
POST /prestamos/solicitar/{libroId}
Submits a loan request for a specific book, creating a pending loan record for admin review
Data Model
The catalog works with theLibro model:
Features Summary
Visual Browsing
Grid layout with book covers, badges, and metadata for easy scanning
Real-time Availability
Dynamic availability status prevents requests for unavailable books
One-Click Requests
Simple workflow to request loans with confirmation dialogs
Responsive Design
Adapts to different screen sizes with Bootstrap responsive grid
Related Features
- Loan Management - Admin panel for approving/rejecting loan requests
- Admin Panel - Manage books, authors, and genres in the catalog