'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 { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' import { Label } from '@/components/ui/label' import { Alert, AlertDescription } from '@/components/ui/alert' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Shield, MapPin, Download, QrCode, AlertCircle, Lock, Globe, Zap, Eye } from 'lucide-react' import { useAuth } from '@/contexts/AuthContext' import { env } from 'process' interface VPNLocation { code: string name: string flag: string popular?: boolean endpoint: string } export default function VPNPage() { const router = useRouter() const { user } = useAuth() const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [billingCycle, setBillingCycle] = useState<'monthly' | 'yearly'>('monthly') const [selectedLocation, setSelectedLocation] = useState('') const [showConfig, setShowConfig] = useState(false) const [apiEndpoint, setApiEndpoint] = useState('') const [mockConfig, setMockConfig] = useState() // VPN pricing const pricing = { monthly: 300, yearly: 4023, // Save 17% } // Available VPN locations const locations: VPNLocation[] = [ // { code: 'india', name: 'Mumbai, India', flag: '🇮🇳', popular: true }, { code: 'america', name: 'America, USA', flag: '🇺🇸', popular: true, endpoint: 'https://wireguard-vpn.3027622.siliconpin.com/vpn', }, { code: 'europe', name: 'Europe, UK', flag: '🇬🇧', popular: true, endpoint: 'https://wireguard.vps20.siliconpin.com/vpn', }, // { code: 'singapore', name: 'Singapore', flag: '🇸🇬' }, // { code: 'japan', name: 'Tokyo, Japan', flag: '🇯🇵' }, // { code: 'canada', name: 'Toronto, Canada', flag: '🇨🇦' }, ] // Mock user balance const userBalance = 8000 const handleSetupVPN = async (e: React.FormEvent) => { e.preventDefault() setError('') if (!user) { router.push('/auth?redirect=/services/vpn') return } if (!selectedLocation) { setError('Please select a VPN location') return } const totalPrice = pricing[billingCycle] if (userBalance < totalPrice) { setError(`Insufficient balance. You need ₹${totalPrice} but only have ₹${userBalance}`) return } setLoading(true) try { // Generate a unique order ID (you might want to use a proper ID generation) const orderId = `vpn-${Date.now()}` // const orderId = `vpn-${Date.now()}-${user.id.slice(0, 8)}` // Make API request to our backend const response = await fetch('/api/services/deploy-vpn', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ orderId, location: selectedLocation, plan: billingCycle, }), }) if (!response.ok) { const errorData = await response.json() throw new Error(errorData.error || 'Failed to setup VPN service') } const { data } = await response.json() // Set the config content and show the config section setMockConfig(data.config) setShowConfig(true) } catch (err) { setError(err.message || 'Failed to setup VPN service') } finally { setLoading(false) } } const downloadConfig = () => { const blob = new Blob([mockConfig], { type: 'application/octet-stream' }) // force binary const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url // quote filename properly a.setAttribute('download', `siliconpin-vpn-${selectedLocation}.conf`) a.setAttribute('type', 'application/octet-stream') document.body.appendChild(a) a.click() document.body.removeChild(a) URL.revokeObjectURL(url) } console.log('selectedLocation', selectedLocation) return (
Secure, fast, and private VPN service with WireGuard protocol
{mockConfig}
WireGuard protocol for maximum speed
We don't track or store your activity
ChaCha20 encryption for security
Servers across the globe