Overview
ReactFlix allows users to rent movies for a 48-hour viewing period at a lower cost than purchasing. Rentals are tracked using browser localStorage, ensuring persistence across sessions.How Rentals Work
Rental Process
1. Browse
Find a movie in the catalog or detail page
2. Rent
Click the “Alquilar” button with rental price
3. Enjoy
Access your rental for 48 hours
Rental Button Component
TheAlquilerButton (RentalButton) handles the rental transaction:
Button States
- Default: Shows rental price (e.g., “Alquilar por S/ 3.99”)
- Processing: Displays “Procesando…” during rental
- Disabled: Button is disabled while processing to prevent double-rentals
The rental uses Peruvian Sol (S/) currency. Rental prices range from S/ 2.99 to S/ 4.99 depending on the movie.
LocalStorage Persistence
Rentals are stored in the browser’s localStorage to persist across sessions:Saving Rentals
When a user rents a movie, it’s added to localStorage with a timestamp:Loading Rentals
The “Mis Alquileres” (My Rentals) page loads rentals from localStorage:The rental date is stored as an ISO 8601 string (e.g., “2026-03-06T12:30:45.123Z”), making it easy to calculate expiration times.
My Rentals Page
TheAlquileresPage displays all active rentals in a dedicated view:
Rental Management Features
View Rentals
Users can view all their rented movies in a grid layout, similar to the main catalog:- Movie Posters: Visual representation of rented movies
- Metadata: Title, year, duration, and rating
- Quick Access: Click to view full details or watch
Extend Rental Period
Users can extend their rental period for an additional 48 hours:Empty State
When users have no active rentals, a clear message is displayed:Rental Workflow
From Movie Detail Page
- Navigate: User views a movie’s detail page
- See Price: Rental button shows “Alquilar por S/ 3.99”
- Click Rent: Button changes to “Procesando…”
- Confirmation: Alert displays rental confirmation
- Access: Movie appears in “Mis Alquileres” page
Accessing Rentals
- Navigate: User clicks “Mis Alquileres” in navigation
- View Grid: All rented movies displayed in grid
- Extend: Click extend button for additional 48 hours
- Watch: Click movie card to view details and watch
Data Structure
Rental objects stored in localStorage include:User Experience
Visual Feedback
- Button States: Clear indication of processing state
- Confirmation Alerts: Immediate feedback on successful rental
- Loading States: Spinner while fetching rental data
- Empty State: Helpful message when no rentals exist
Navigation
Users can access their rentals from multiple places:- Navigation Menu: “Mis Alquileres” link in header
- After Renting: Confirmation message mentions 48-hour period
- Movie Cards: Rented movies appear in dedicated page
Technical Implementation
Component Hierarchy
Integration with Detail Page
The movie detail page integrates rental functionality:Pricing
Rental prices vary by movie:| Movie | Rental Price | Purchase Price |
|---|---|---|
| The Matrix | S/ 2.99 | S/ 9.99 |
| Pulp Fiction | S/ 2.99 | S/ 10.99 |
| Gladiator | S/ 2.99 | S/ 10.99 |
| The Dark Knight | S/ 3.49 | S/ 11.99 |
| Inception | S/ 3.99 | S/ 12.99 |
| Avatar | S/ 3.99 | S/ 12.99 |
| The Godfather | S/ 3.99 | S/ 13.99 |
| Interstellar | S/ 4.99 | S/ 14.99 |
Rentals are typically 30-40% of the purchase price, making them attractive for one-time viewing.
Browser Compatibility
The rental system uses localStorage, which is supported by all modern browsers:- Storage Limit: 5-10 MB per domain
- Persistence: Data survives browser restarts
- Accessibility: Available in all tabs/windows of same domain
If users clear browser data or use incognito mode, rentals will be lost. Consider implementing user accounts for production.
Future Enhancements
- Expiration Timer: Show countdown for 48-hour rental period
- Auto-Removal: Delete expired rentals automatically
- Rental History: Track past rentals even after expiration
- Payment Integration: Connect to real payment gateway
- Download Option: Allow offline viewing during rental period
- Multiple Profiles: Separate rental libraries per user
Next Steps
Purchase Movies
Learn about buying movies for permanent access
Movie Details
Explore the detailed movie page where rentals happen