'use client' import { useState } from 'react' import { motion } from 'framer-motion' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Textarea } from '@/components/ui/textarea' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import { Badge } from '@/components/ui/badge' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Store, User, Mail, Phone, MapPin, Building, FileText, CheckCircle, Loader2, Gift } from 'lucide-react' import { toast } from 'sonner' interface WholesalerRegistrationFormProps { isOpen: boolean onClose: () => void } interface WholesalerFormData { // Business Information businessName: string businessType: string gstNumber: string panNumber: string // Personal Information firstName: string lastName: string email: string phone: string // Address Information address: string city: string state: string zipCode: string // Business Details experience: string expectedOrderVolume: string productCategories: string businessDescription: string } export default function WholesalerRegistrationForm({ isOpen, onClose }: WholesalerRegistrationFormProps) { const [formData, setFormData] = useState({ businessName: '', businessType: '', gstNumber: '', panNumber: '', firstName: '', lastName: '', email: '', phone: '', address: '', city: '', state: '', zipCode: '', experience: '', expectedOrderVolume: '', productCategories: '', businessDescription: '' }) const [loading, setLoading] = useState(false) const [showSuccessModal, setShowSuccessModal] = useState(false) const [loginCredentials, setLoginCredentials] = useState<{ email: string password: string } | null>(null) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) try { const response = await fetch('/api/wholesaler/register', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(formData), }) const data = await response.json() if (!response.ok) { throw new Error(data.message || 'Registration failed') } setLoginCredentials(data.loginCredentials) setShowSuccessModal(true) onClose() // Close the main registration modal // Reset form setFormData({ businessName: '', businessType: '', gstNumber: '', panNumber: '', firstName: '', lastName: '', email: '', phone: '', address: '', city: '', state: '', zipCode: '', experience: '', expectedOrderVolume: '', productCategories: '', businessDescription: '' }) toast.success('Wholesaler registration successful!') } catch (error) { console.error('Registration error:', error) toast.error(error instanceof Error ? error.message : 'Registration failed') } finally { setLoading(false) } } const handleInputChange = (field: keyof WholesalerFormData, value: string) => { setFormData(prev => ({ ...prev, [field]: value })) } return ( <> Wholesaler Registration Join our network and get exclusive access to premium products with 25% wholesale discount on bulk orders
25% Discount Bulk Orders
{/* Business Information */}

Business Information

handleInputChange('businessName', e.target.value)} placeholder="Enter your business name" required />
handleInputChange('gstNumber', e.target.value)} placeholder="Enter GST number" />
handleInputChange('panNumber', e.target.value)} placeholder="Enter PAN number" />
{/* Personal Information */}

Personal Information

handleInputChange('firstName', e.target.value)} placeholder="Enter your first name" required />
handleInputChange('lastName', e.target.value)} placeholder="Enter your last name" required />
handleInputChange('email', e.target.value)} placeholder="Enter your email address" required />
handleInputChange('phone', e.target.value)} placeholder="Enter your phone number" required />
{/* Address Information */}

Address Information