'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 (
Professional web hosting with your preferred control panel
Install WordPress, Joomla, and more with one click
Secure your website with free SSL certificates
Automatic daily backups with easy restore
Create professional email addresses