Overview
ReactFlix allows users to purchase movies for permanent, unlimited access. Purchased movies are stored in the browser’s localStorage and can be accessed anytime from the “Mis Compras” (My Purchases) page.How Purchases Work
Purchase Process
1. Select
Choose a movie from the catalog or detail page
2. Buy
Click the “Comprar” button with purchase price
3. Own Forever
Unlimited access with no expiration
Purchase Button Component
TheCompraButton (PurchaseButton) manages the buying transaction:
Button States
- Default: Shows purchase price (e.g., “Comprar por 12.99€”)
- Processing: Displays “Procesando…” during transaction
- Disabled: Button disabled during processing to prevent duplicate purchases
The purchase button uses Euro (€) currency, while rentals use Peruvian Sol (S/). This is a quirk of the demo app that could be standardized in production.
LocalStorage Persistence
Purchases are permanently stored in the browser’s localStorage:Saving Purchases
When a user buys a movie, it’s saved with a purchase timestamp:Loading Purchases
The “Mis Compras” (My Purchases) page loads all purchases on mount:Purchase dates are stored as ISO 8601 strings (e.g., “2026-03-06T14:30:00.000Z”), useful for sorting and displaying purchase history.
My Purchases Page
TheComprasPage displays the user’s complete movie library:
Library Features
Visual Display
Purchased movies appear in a familiar grid layout:- Movie Posters: Full collection displayed visually
- Metadata: Title, year, duration, rating
- Unlimited Access: No expiration dates or restrictions
- Quick Actions: Watch trailers, view details anytime
Empty State
New users see a helpful message when their library is empty:Purchase Workflow
From Movie Detail Page
- Browse: User views movie detail page
- Compare: See both rental (S/ 3.99) and purchase (12.99€) options
- Decide: Choose purchase for permanent access
- Click Buy: Button shows “Procesando…”
- Confirmation: Alert confirms successful purchase
- Access: Movie appears in “Mis Compras” library
Accessing Library
- Navigate: Click “Mis Compras” in site navigation
- View Collection: All owned movies displayed in grid
- Enjoy: Watch trailers or full movies anytime
- Re-watch: No limits on viewing frequency
Data Structure
Purchase objects in localStorage include:Integration with Detail Page
The movie detail page offers both rental and purchase options side-by-side:Pricing Overview
Purchase prices range from €9.99 to €14.99:| Movie | Purchase Price | Rental Price | Savings vs. 5 Rentals |
|---|---|---|---|
| The Matrix | €9.99 | S/ 2.99 | 33% |
| Pulp Fiction | €10.99 | S/ 2.99 | 39% |
| Gladiator | €10.99 | S/ 2.99 | 39% |
| The Dark Knight | €11.99 | S/ 3.49 | 31% |
| Inception | €12.99 | S/ 3.99 | 35% |
| Avatar | €12.99 | S/ 3.99 | 35% |
| The Godfather | €13.99 | S/ 3.99 | 40% |
| Interstellar | €14.99 | S/ 4.99 | 40% |
Purchasing becomes cost-effective after approximately 3-5 rentals, depending on the movie.
User Experience
Visual Feedback
- Button Animation: Processing state prevents confusion
- Confirmation Alert: Immediate success message with price
- Library Update: Purchase appears instantly in “Mis Compras”
- Loading States: Smooth spinner while fetching library
Navigation Flow
Users can access purchases from:- Header Navigation: “Mis Compras” link always visible
- Post-Purchase: Confirmation message can link to library
- Profile/Account: Natural place for library access
Component Architecture
Rental vs. Purchase Decision
When to Rent
- One-time viewing: Only plan to watch once
- Budget conscious: Lower upfront cost
- Testing: Want to preview before buying
- Time-sensitive: Don’t need long-term access
When to Purchase
- Favorites: Movies you’ll watch multiple times
- Collection building: Creating a digital library
- Convenience: Unlimited, permanent access
- Cost-effective: Better value after 3-5 viewings
Technical Considerations
Storage
- localStorage Limit: Typically 5-10 MB
- Movie Data: Each movie ~1-2 KB
- Capacity: Can store hundreds of purchases
- Persistence: Survives browser restarts
Browser Compatibility
All modern browsers support localStorage. However, data is lost if users clear browser data or use private/incognito mode.
Security Considerations
Current Implementation
- Client-side Only: All data stored locally
- No Authentication: No user accounts
- No Payment: Simulated transactions
Production Recommendations
- User Accounts: Cloud-based purchase history
- Payment Gateway: Stripe, PayPal integration
- DRM: Digital rights management for content
- License Verification: Server-side validation
- Cross-device Sync: Access library on any device
Duplicate Prevention
The current implementation allows duplicate purchases. Consider adding:Future Enhancements
- Purchase History: Show purchase dates and sorting options
- Wishlist: Save movies for future purchase
- Gift Purchases: Buy movies for others
- Bundles: Discounted multi-movie packages
- Collections: Create custom playlists
- Sharing: Share owned movies with family accounts
- Download: Offline viewing capability
- Quality Options: HD, 4K purchase tiers
Analytics Opportunities
- Conversion Rate: Rental to purchase conversion
- Popular Purchases: Most-bought movies
- Revenue Tracking: Total purchase value
- User Behavior: Browse-to-buy time
Next Steps
Movie Rentals
Compare with the rental system for temporary access
Movie Details
See where purchase options are displayed