import React, { useState, useEffect } from 'react'; import './SubscriptionPortal.css'; // Mock data for demonstration purposes const mockSubscriptionData = { tiers: [ { id: 1, name: "FlexRide", price: 499, description: "Basic access to Unity Fleet vehicles with pay-per-use model", features: [ { name: "24/7 Vehicle Access", included: true }, { name: "Basic Charging Access", included: true }, { name: "Vehicle Variety", included: true, details: "Sedans & Compact SUVs" }, { name: "Monthly Credits", included: true, details: "500 credits" }, { name: "Reservation Priority", included: false }, { name: "Premium Charging", included: false }, { name: "Lounge Access", included: false }, { name: "Home Charging Setup", included: false }, { name: "Dedicated Vehicle", included: false }, { name: "ChainLink Tokens", included: true, details: "5 tokens/month" } ], popular: false, color: "#00E0FF" }, { id: 2, name: "Take-Home", price: 1299, description: "Dedicated vehicle for personal use with enhanced benefits", features: [ { name: "24/7 Vehicle Access", included: true }, { name: "Basic Charging Access", included: true }, { name: "Vehicle Variety", included: true, details: "All Vehicle Types" }, { name: "Monthly Credits", included: true, details: "1500 credits" }, { name: "Reservation Priority", included: true }, { name: "Premium Charging", included: true }, { name: "Lounge Access", included: true, details: "Standard Access" }, { name: "Home Charging Setup", included: true }, { name: "Dedicated Vehicle", included: true }, { name: "ChainLink Tokens", included: true, details: "15 tokens/month" } ], popular: true, color: "#35F2DB" }, { id: 3, name: "All-Access", price: 1999, description: "Complete mobility solution with premium benefits and maximum flexibility", features: [ { name: "24/7 Vehicle Access", included: true }, { name: "Basic Charging Access", included: true }, { name: "Vehicle Variety", included: true, details: "All Vehicle Types + Premium" }, { name: "Monthly Credits", included: true, details: "Unlimited" }, { name: "Reservation Priority", included: true }, { name: "Premium Charging", included: true }, { name: "Lounge Access", included: true, details: "VIP Access" }, { name: "Home Charging Setup", included: true }, { name: "Dedicated Vehicle", included: true, details: "Multiple Vehicles" }, { name: "ChainLink Tokens", included: true, details: "30 tokens/month" } ], popular: false, color: "#FFC107" } ], addOns: [ { id: 101, name: "Additional Driver", price: 99, description: "Add an additional authorized driver to your account" }, { id: 102, name: "Premium Insurance", price: 149, description: "Enhanced insurance coverage with lower deductible" }, { id: 103, name: "Charging Credit Pack", price: 199, description: "Additional 500 charging credits" }, { id: 104, name: "Road Trip Package", price: 249, description: "Extended range access and premium roadside assistance" }, { id: 105, name: "Token Booster", price: 299, description: "Additional 10 ChainLink tokens per month" } ], userProfile: { name: "Matthew Lamb", email: "matthew@example.com", currentPlan: "Take-Home", memberSince: "January 2025", credits: 1250, tokens: 45, paymentMethod: "Visa ending in 4242", nextBillingDate: "May 1, 2025" }, usageHistory: [ { date: "April 5, 2025", activity: "Vehicle Reservation", vehicle: "Tesla Model 3", credits: 150, location: "Downtown Hub" }, { date: "April 3, 2025", activity: "Premium Charging", vehicle: "Tesla Model 3", credits: 75, location: "Westside Station" }, { date: "March 28, 2025", activity: "Lounge Access", vehicle: null, credits: 50, location: "University Hub" }, { date: "March 25, 2025", activity: "Vehicle Reservation", vehicle: "Tesla Model Y", credits: 200, location: "Downtown Hub" }, { date: "March 20, 2025", activity: "Token Redemption", vehicle: null, credits: 0, tokens: 10, location: null } ] }; function SubscriptionPortal() { const [activeTab, setActiveTab] = useState('plans'); const [loading, setLoading] = useState(true); const [selectedTier, setSelectedTier] = useState(null); const [selectedAddOns, setSelectedAddOns] = useState([]); const [billingCycle, setBillingCycle] = useState('monthly'); const [showConfirmation, setShowConfirmation] = useState(false); useEffect(() => { // Simulate loading const timer = setTimeout(() => { setLoading(false); // Set the user's current plan as selected const currentPlan = mockSubscriptionData.tiers.find( tier => tier.name === mockSubscriptionData.userProfile.currentPlan ); setSelectedTier(currentPlan); }, 1500); return () => clearTimeout(timer); }, []); const handleTierSelect = (tier) => { setSelectedTier(tier); setShowConfirmation(false); }; const handleAddOnToggle = (addOn) => { if (selectedAddOns.some(item => item.id === addOn.id)) { setSelectedAddOns(selectedAddOns.filter(item => item.id !== addOn.id)); } else { setSelectedAddOns([...selectedAddOns, addOn]); } setShowConfirmation(false); }; const handleBillingCycleChange = (cycle) => { setBillingCycle(cycle); setShowConfirmation(false); }; const calculateTotalPrice = () => { if (!selectedTier) return 0; let basePrice = selectedTier.price; if (billingCycle === 'annual') { basePrice = basePrice * 10; // 2 months free for annual billing } const addOnsTotal = selectedAddOns.reduce((sum, addOn) => { let addOnPrice = addOn.price; if (billingCycle === 'annual') { addOnPrice = addOnPrice * 10; // 2 months free for annual billing } return sum + addOnPrice; }, 0); return basePrice + addOnsTotal; }; const handleSubscribe = () => { setShowConfirmation(true); }; const renderFeatureComparison = () => { // Get all unique features across all tiers const allFeatures = Array.from( new Set( mockSubscriptionData.tiers.flatMap(tier => tier.features.map(feature => feature.name) ) ) ); return (

Feature Comparison

Feature
{mockSubscriptionData.tiers.map(tier => (
{tier.name}
))}
{allFeatures.map((featureName, index) => (
{featureName}
{mockSubscriptionData.tiers.map(tier => { const feature = tier.features.find(f => f.name === featureName); return (
{feature && feature.included ? (
{feature.details && {feature.details}}
) : (
)}
); })}
))}
); }; if (loading) { return (
Unity Fleet

Loading Subscription Portal...

); } return (

Subscription Portal

Unity Fleet Membership
Profile
{mockSubscriptionData.userProfile.name}
{mockSubscriptionData.userProfile.currentPlan} Member
{activeTab === 'plans' && (

Your Current Plan: {mockSubscriptionData.userProfile.currentPlan}

Member since {mockSubscriptionData.userProfile.memberSince} • Next billing date: {mockSubscriptionData.userProfile.nextBillingDate}

Monthly Annual Save 16%
{mockSubscriptionData.tiers.map(tier => (
handleTierSelect(tier)} > {tier.popular &&
Most Popular
}

{tier.name}

${tier.price} /{billingCycle === 'monthly' ? 'mo' : 'yr'}
{billingCycle === 'annual' && (
Save ${tier.price * 2} with annual billing
)}
{tier.description}
    {tier.features.slice(0, 5).map((feature, index) => (
  • {feature.included ? '✓' : '—'} {feature.name} {feature.included && feature.details && ( ({feature.details}) )}
  • ))}
{mockSubscriptionData.userProfile.currentPlan === tier.name ? ( ) : ( )}
))}
{selectedTier && (

Available Add-Ons

{mockSubscriptionData.addOns.map(addOn => (
item.id === addOn.id) ? 'selected' : ''}`} onClick={() => handleAddOnToggle(addOn)} >

{addOn.name}

{addOn.description}

${addOn.price}/{billingCycle === 'monthly' ? 'mo' : 'yr'}
))}
)} {selectedTier && (

Subscription Summary

{selectedTier.name} Plan ${billingCycle === 'monthly' ? selectedTier.price : selectedTier.price * 10}/ {billingCycle === 'monthly' ? 'mo' : 'yr'}
{selectedAddOns.map(addOn => (
{addOn.name} ${billingCycle === 'monthly' ? addOn.price : addOn.price * 10}/ {billingCycle === 'monthly' ? 'mo' : 'yr'}
))}
Total ${calculateTotalPrice()}/{billingCycle === 'monthly' ? 'mo' : 'yr'}
)} {showConfirmation && (

Confirm Your Subscription

Selected Plan: {selectedTier.name}
Billing Cycle: {billingCycle === 'monthly' ? 'Monthly' : 'Annual'}
{selectedAddOns.length > 0 && (
Add-Ons: {selectedAddOns.map(addOn => addOn.name).join(', ')}
)}
Total Price: ${calculateTotalPrice()}/{billingCycle === 'monthly' ? 'mo' : 'yr'}
Payment Method: {mockSubscriptionData.userProfile.paymentMethod}
)}
)} {activeTab === 'account' && (

Profile Information

Name: {mockSubscriptionData.userProfile.name}
Email: {mockSubscriptionData.userProfile.email}
Member Since: {mockSubscriptionData.userProfile.memberSince}
Current Plan: {mockSubscriptionData.userProfile.currentPlan}

Account Balance

🔋
{mockSubscriptionData.userProfile.credits}
Available Credits
{mockSubscriptionData.userProfile.tokens}
ChainLink Tokens

Payment Information

💳
{mockSubscriptionData.userProfile.paymentMethod}
Next billing: {mockSubscriptionData.userProfile.nextBillingDate}

Recent Payments

April 1, 2025
Monthly Subscription - {mockSubscriptionData.userProfile.currentPlan}
$1,299.00
March 1, 2025
Monthly Subscription - {mockSubscriptionData.userProfile.currentPlan}
$1,299.00
February 1, 2025
Monthly Subscription - {mockSubscriptionData.userProfile.currentPlan}
$1,299.00

Account Preferences

Email Notifications
SMS Alerts
Reservation Reminders
Special Offers
)} {activeTab === 'usage' && (

Credit Usage

Jan
Feb
Mar
Apr
Monthly Allocation
1,500 credits
Used This Month
250 credits
Remaining
1,250 credits

Token Balance

{mockSubscriptionData.userProfile.tokens}
ChainLink Tokens
Monthly Accrual: 15 tokens
Next Distribution: May 1, 2025
Lifetime Earned: 60 tokens

Recent Activity

{mockSubscriptionData.usageHistory.map((activity, index) => (
{activity.date}
{activity.activity}
{activity.vehicle &&
{activity.vehicle}
} {activity.location &&
{activity.location}
}
{activity.credits > 0 &&
-{activity.credits} credits
} {activity.tokens > 0 &&
-{activity.tokens} tokens
}
))}

Usage Insights

🚗
Most Used Vehicle
Tesla Model 3
8 reservations this month
Favorite Charging Location
Downtown Hub
12 charging sessions
📊
Average Trip Length
42 miles
Based on last 20 trips
💰
Estimated Savings
$345
Compared to traditional ownership
)} {activeTab === 'compare' && (
{renderFeatureComparison()}

Membership Benefits

🔄

Flexibility

Change or upgrade your plan at any time to match your evolving mobility needs.

💰

Cost Savings

Save on insurance, maintenance, and depreciation costs compared to traditional ownership.

Charging Network

Access to The Link's growing network of premium charging stations across Illinois.

Token Ownership

Earn ChainLink tokens with every subscription payment, building equity in the network.

Frequently Asked Questions

How do subscription credits work?

Subscription credits are allocated monthly based on your plan tier. These credits can be used for vehicle reservations, charging sessions, and lounge access. Unused credits roll over for up to 3 months.

Can I change my plan?

Yes, you can upgrade or downgrade your plan at any time. Changes take effect at the start of your next billing cycle. Upgrades may be applied immediately upon request.

What are ChainLink tokens?

ChainLink tokens represent fractional ownership in The Link charging infrastructure. Tokens are earned monthly with your subscription and can be redeemed for charging credits, subscription discounts, or held as an appreciating asset.

How does the home charging setup work?

Take-Home and All-Access plans include installation of a Level 2 home charger at your residence. Our team will coordinate installation with a certified electrician. Installation costs are covered up to $1,000.

)}
); } export default SubscriptionPortal;