'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 { Textarea } from '@/components/ui/textarea'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Badge } from '@/components/ui/badge'
import {
Clock,
Calendar,
CalendarDays,
Users,
Code,
Briefcase,
CheckCircle,
AlertCircle,
Star,
} from 'lucide-react'
import { useAuth } from '@/contexts/AuthContext'
import { useToast } from '@/hooks/use-toast'
import { formatCurrency, validateBalance } from '@/lib/balance-service'
interface DeveloperPlan {
id: string
name: string
price: string
value: number
icon: React.ReactNode
popular: boolean
features: string[]
description: string
}
export default function HumanDeveloperPage() {
const router = useRouter()
const { user, balance, refreshBalance } = useAuth()
const { toast } = useToast()
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [success, setSuccess] = useState('')
// Form state
const [selectedPlan, setSelectedPlan] = useState('')
const [requirements, setRequirements] = useState('')
const [contactInfo, setContactInfo] = useState({
name: user?.name || '',
email: user?.email || '',
phone: '',
})
// Available developer plans
const plans: DeveloperPlan[] = [
{
id: 'hourly',
name: 'Hourly',
price: '₹2,000',
value: 2000,
icon: ,
popular: false,
description: 'Perfect for quick fixes and consultations',
features: [
'Flexible hours',
'Pay as you go',
'Minimum 2 hours',
'Quick fixes & bug fixes',
'Technical consultation',
],
},
{
id: 'daily',
name: 'Daily',
price: '₹5,000',
value: 5000,
icon: ,
popular: true,
description: 'Best for short-term projects and rapid development',
features: [
'8 hours per day',
'Priority support',
'Daily progress reports',
'Dedicated developer',
'Progress tracking',
],
},
{
id: 'monthly',
name: 'Monthly',
price: '₹1,00,000',
value: 100000,
icon: ,
popular: false,
description: 'Complete solution for large projects',
features: [
'Full-time developer (160+ hours)',
'Dedicated project manager',
'Weekly sprint planning',
'Complete project planning',
'Priority feature development',
],
},
]
// Technology expertise areas
const techStack = [
'React & Next.js',
'Node.js',
'Python',
'PHP',
'Laravel',
'Vue.js',
'Angular',
'React Native',
'Flutter',
'WordPress',
'Shopify',
'Database Design',
'API Development',
'DevOps',
'UI/UX Design',
'Mobile Apps',
'E-commerce',
'CMS Development',
]
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError('')
setSuccess('')
if (!user) {
router.push('/auth?redirect=/services/human-developer')
return
}
// Validate form
if (!selectedPlan) {
setError('Please select a plan')
return
}
if (!requirements.trim()) {
setError('Please describe your project requirements')
return
}
if (!contactInfo.name || !contactInfo.email) {
setError('Please fill in all contact information')
return
}
const selectedPlanData = plans.find((p) => p.id === selectedPlan)
if (!selectedPlanData) {
setError('Invalid plan selected')
return
}
// Check balance before proceeding
const minimumDeposit = selectedPlanData.value * 0.5
if (!validateBalance(balance || 0, minimumDeposit)) {
setError(
`Insufficient balance. Minimum deposit required: ${formatCurrency(minimumDeposit)}, Available: ${formatCurrency(balance || 0)}`
)
return
}
setLoading(true)
try {
const response = await fetch('/api/services/hire-developer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
planId: selectedPlan,
planName: selectedPlanData.name,
planPrice: selectedPlanData.value,
requirements: requirements.trim(),
contactInfo: {
name: contactInfo.name.trim(),
email: contactInfo.email.trim(),
phone: contactInfo.phone?.trim() || undefined,
},
}),
})
const data = await response.json()
if (!response.ok) {
throw new Error(data.error?.message || 'Failed to submit request')
}
if (data.success) {
setSuccess(data.data.message)
toast({
title: 'Request Submitted Successfully!',
description: `Deposit of ${formatCurrency(minimumDeposit)} has been deducted. Request ID: ${data.data.requestId}`,
})
// Refresh user balance
await refreshBalance()
// Reset form
setSelectedPlan('')
setRequirements('')
setContactInfo({
name: user?.name || '',
email: user?.email || '',
phone: '',
})
} else {
throw new Error(data.error?.message || 'Failed to submit request')
}
} catch (err) {
console.error('Developer hire error:', err)
const errorMessage = err instanceof Error ? err.message : 'Failed to submit request'
setError(errorMessage)
toast({
title: 'Request Failed',
description: errorMessage,
variant: 'destructive',
})
} finally {
setLoading(false)
}
}
return (
{/* Page Header */}
Hire Expert Developers
Get skilled developers for your projects. From quick fixes to full-scale applications.
{!user && (
You need to be logged in to hire developers.{' '}
Click here to login
)}
{success && (
{success}
)}
{/* Why Choose Us */}
Why Choose Our Developers?
Expert Skills
5+ years experience in modern tech stacks
Quality Assured
Code reviews and testing included
On-Time Delivery
Meeting deadlines is our priority
Full Support
Post-delivery support and maintenance
)
}