Overview
ThePrestamoListComponent provides administrators with a view of all loan requests in the system. Admins can approve or reject pending loan requests, and view the history of all loans.
Component Metadata
app-prestamo-list
Imports:
CommonModule- Angular common directives
./prestamo-list.html
Properties
prestamos
Prestamo object includes:
id: Loan request identifierlibro: Book object with title and detailsusuario: User who requested the loanfechaSolicitud: Date when the loan was requestedestado: Loan status (PENDIENTE, APROBADO, RECHAZADO)
Injected Services
- PrestamoService - Handles all loan-related API operations
Lifecycle Hooks
ngOnInit
Methods
cargarPrestamos
PrestamoService:
- Calls
PrestamoService.getAll() - Sorts the results by ID in descending order (newest first)
- Populates the
prestamosarray
aprobar
- Displays confirmation dialog “¿Aprobar este préstamo? El libro dejará de estar disponible.”
- If confirmed, calls
PrestamoService.aprobar()with the loan ID - On success:
- Shows alert “Préstamo Aprobado”
- Reloads the loan list by calling
cargarPrestamos()
disponible status is set to false by the backend.
Parameters:
id- The numeric ID of the loan request to approve
rechazar
- Displays confirmation dialog “¿Rechazar solicitud?”
- If confirmed, calls
PrestamoService.rechazar()with the loan ID - On success:
- Shows alert “Solicitud Rechazada”
- Reloads the loan list by calling
cargarPrestamos()
id- The numeric ID of the loan request to reject
Full Source Code
Related Components
- CatalogoComponent - Where users request loans
- LibroListComponent - Manage book availability
Related Services
- PrestamoService - Loan CRUD and approval operations