'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Header } from '@/components/header' import { Footer } from '@/components/footer' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' import { Alert, AlertDescription } from '@/components/ui/alert' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Server, Shield, HardDrive, Globe, Mail, AlertCircle, Check, Settings } from 'lucide-react' import { useAuth } from '@/contexts/AuthContext' interface HostingPlan { id: string controlPanel: string billingCycle: string[] price: { monthly: number yearly: number } storage: string bandwidth: string domainsAllowed: string ssl: boolean support: string popular?: boolean } export default function HostingControlPanelPage() { const router = useRouter() const { user } = useAuth() const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [billingCycle, setBillingCycle] = useState<'monthly' | 'yearly'>('monthly') const [selectedPlan, setSelectedPlan] = useState('') const [domain, setDomain] = useState('') // Available hosting plans const plans: HostingPlan[] = [ { id: 'plan_001', controlPanel: 'cPanel', billingCycle: ['monthly', 'yearly'], price: { monthly: 500, yearly: 5000 }, storage: '100 GB SSD', bandwidth: 'Unlimited', domainsAllowed: 'Unlimited', ssl: true, support: '24/7 Priority Support', popular: true, }, { id: 'plan_002', controlPanel: 'Plesk', billingCycle: ['monthly', 'yearly'], price: { monthly: 450, yearly: 4500 }, storage: '80 GB SSD', bandwidth: 'Unlimited', domainsAllowed: '50', ssl: true, support: '24/7 Support', }, { id: 'plan_003', controlPanel: 'DirectAdmin', billingCycle: ['monthly', 'yearly'], price: { monthly: 350, yearly: 3500 }, storage: '60 GB SSD', bandwidth: '2TB/month', domainsAllowed: '25', ssl: true, support: 'Email & Chat', }, { id: 'plan_004', controlPanel: 'HestiaCP', billingCycle: ['monthly', 'yearly'], price: { monthly: 199, yearly: 1999 }, storage: '50 GB SSD', bandwidth: 'Unlimited', domainsAllowed: 'Unlimited', ssl: true, support: 'Email & Chat', }, { id: 'plan_005', controlPanel: 'Webmin', billingCycle: ['monthly', 'yearly'], price: { monthly: 149, yearly: 1499 }, storage: '40 GB SSD', bandwidth: 'Unlimited', domainsAllowed: '10', ssl: true, support: 'Email Only', }, { id: 'plan_006', controlPanel: 'VestaCP', billingCycle: ['monthly', 'yearly'], price: { monthly: 129, yearly: 1299 }, storage: '30 GB SSD', bandwidth: '500 GB/month', domainsAllowed: '5', ssl: true, support: 'Email Only', }, ] // Mock user balance const userBalance = 10000 const handlePurchase = async (e: React.FormEvent) => { e.preventDefault() setError('') if (!user) { router.push('/auth?redirect=/services/hosting-control-panel') return } // Validate form if (!domain || !selectedPlan) { setError('Please fill in all required fields') return } // Validate domain format const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/ if (!domainRegex.test(domain)) { setError('Please enter a valid domain name') return } // Get selected plan price const plan = plans.find(p => p.id === selectedPlan) if (!plan) { setError('Please select a valid plan') return } const totalPrice = plan.price[billingCycle] // Check balance if (userBalance < totalPrice) { setError(`Insufficient balance. You need ₹${totalPrice.toFixed(2)} but only have ₹${userBalance.toFixed(2)}`) return } setLoading(true) // Simulate API call setTimeout(() => { setLoading(false) alert('Hosting package purchased successfully! (This is a demo - no actual purchase)') }, 2000) } return (
{/* Page Header */}

Hosting Control Panels

Professional web hosting with your preferred control panel

{!user && ( You need to be logged in to purchase hosting.{' '} Click here to login )}
{/* Billing Cycle Selection */} Billing Cycle Choose your preferred billing period setBillingCycle(v as 'monthly' | 'yearly')}> Monthly Yearly (Save 17%) {/* Available Plans */}

Choose Your Control Panel

{plans.map((plan) => ( setSelectedPlan(plan.id)} > {plan.popular && (
Most Popular
)} {plan.controlPanel}
₹{plan.price[billingCycle]} /{billingCycle === 'monthly' ? 'month' : 'year'}
{plan.storage}
{plan.bandwidth} Bandwidth
{plan.domainsAllowed} Domains
{plan.ssl && (
Free SSL Certificate
)}
{plan.support}
))}
{/* Domain Configuration */} Domain Configuration Enter the primary domain for your hosting account
setDomain(e.target.value)} required />

You can add more domains later from your control panel

{/* Order Summary */} {selectedPlan && ( Order Summary
Control Panel {plans.find(p => p.id === selectedPlan)?.controlPanel}
Billing Cycle {billingCycle}
Total ₹{plans.find(p => p.id === selectedPlan)?.price[billingCycle]}
Your Balance = (plans.find(p => p.id === selectedPlan)?.price[billingCycle] || 0) ? 'text-green-600' : 'text-red-600'}> ₹{userBalance.toFixed(2)}
)} {error && ( {error} )} {/* Purchase Button */}
{/* Features Grid */}

All Plans Include

One-Click Apps

Install WordPress, Joomla, and more with one click

Free SSL

Secure your website with free SSL certificates

Daily Backups

Automatic daily backups with easy restore

Email Accounts

Create professional email addresses

) }