Overview
CompraButton (exported as PurchaseButton in source) is a button component that handles movie purchase transactions. It displays the purchase price, simulates a processing delay, and provides feedback to the user.
Import
Props
Movie object containing purchase informationRequired properties:
title(string): Movie title (used in confirmation message)price(number): Purchase price in currency units
Callback function invoked when the purchase process completesSignature:
(pelicula: object) => voidParameters:pelicula(object): The movie object that was purchased
Component Signature
Internal State
Tracks whether a purchase transaction is in progress. When
true, the button displays “Procesando…” and is disabled.Features
Simulated Transaction
Simulates a 500ms purchase processing delay:Loading State
Button text and disabled state change during processing:User Feedback
Displays an alert with purchase confirmation:Usage Example
- In Detail Page
- Basic Usage
Rendered Structure
Button States
| State | Text | Disabled | Behavior |
|---|---|---|---|
| Idle | Comprar por {price}€ | false | Clickable, starts purchase |
| Processing | Procesando... | true | Not clickable, purchase in progress |
Purchase Flow
CSS Classes
.compra-button- Main button element
Currency Format
The component uses Euros (€) in the button text and alert message:There’s a currency inconsistency in the application:
CompraButton uses Euros (€) while AlquilerButton uses Peruvian Soles (S/).Comparison with AlquilerButton
| Feature | CompraButton | AlquilerButton |
|---|---|---|
| Currency | Euros (€) | Peruvian Soles (S/) |
| Price prop | pelicula.price | pelicula.alquilerPrecio |
| Duration | Permanent | 48 hours |
| Callback | onPurchase | onRent |
| Class name | .compra-button | .alquiler-button |
Source Location
src/components/CompraButton.jsx:3