Skip to main content

Overview

The Prestamo interface represents a book loan in the virtual library system. It tracks loan requests, approvals, rejections, and returns.

Interface Definition

Properties

Basic Properties

number
required
Unique identifier for the loan. Auto-generated by the backend.
string
required
The date and time when the loan was requested. Typically in ISO 8601 format (e.g., "2024-03-15T10:30:00").
string
Optional return date for the book. Set when the book is returned or when an approved loan has a due date.
'PENDIENTE' | 'APROBADO' | 'RECHAZADO'
required
The current status of the loan request:
  • PENDIENTE: Loan request is pending approval
  • APROBADO: Loan has been approved by an administrator
  • RECHAZADO: Loan request has been rejected

Relationships

Libro
required
The book being loaned. See Libro interface for details.
any
required
The user who requested the loan. This is the complete user object returned from the Spring Boot backend.

Estado Enum

The estado property uses a string literal union type with three possible values:

Estado Values

string
Initial state when a user requests a book loan. Awaiting administrator approval.
string
The loan has been approved by an administrator. The book is now marked as unavailable.
string
The loan request has been rejected by an administrator.

Usage Examples

Requesting a Loan (User)

Viewing All Loans (Admin)

Viewing User’s Own Loans

Approving a Loan (Admin)

Rejecting a Loan (Admin)

Filtering Loans by Status

Checking Book Availability Before Requesting

Template Usage

Component Implementation Example

  • Libro - Book interface referenced by Prestamo
  • Autor - Author interface (referenced through Libro)
  • Genero - Genre interface (referenced through Libro)

Business Rules

When a loan is approved (APROBADO), the associated book’s disponible property is automatically set to false by the backend.
Users can only request loans for books where libro.disponible === true. The backend will reject requests for unavailable books.
The fechaSolicitud is automatically set by the backend when the loan is created. You don’t need to provide it when requesting a loan.

Notes

Consider implementing date formatting utilities to display fechaSolicitud and fechaDevolucion in a user-friendly format.
The usuario field contains the complete user object from Spring Boot. The exact structure depends on your backend User model.