"use client" import type React from "react" import { useState } from "react" 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 { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import type { Client } from "@/types/business" interface ClientFormProps { client?: Client open: boolean onOpenChange: (open: boolean) => void onSubmit: (client: Omit) => void } const paymentTerms = ["Net 15", "Net 30", "Net 45", "Net 60", "COD", "Prepaid", "Custom"] export function ClientForm({ client, open, onOpenChange, onSubmit }: ClientFormProps) { const [formData, setFormData] = useState({ name: client?.name || "", email: client?.email || "", phone: client?.phone || "", address: client?.address || "", creditLimit: client?.creditLimit || 0, paymentTerms: client?.paymentTerms || "Net 30", notes: client?.notes || "", contactPerson: client?.contactPerson || "", businessType: client?.businessType || "", }) const handleSubmit = (e: React.FormEvent) => { e.preventDefault() onSubmit({ ...formData, outstandingAmount: client?.outstandingAmount || 0, }) onOpenChange(false) // Reset form if it's a new client if (!client) { setFormData({ name: "", email: "", phone: "", address: "", creditLimit: 0, paymentTerms: "Net 30", notes: "", contactPerson: "", businessType: "", }) } } return ( {client ? "Edit Client" : "Add New Client"} {client ? "Update client information" : "Enter the details for the new client"}
setFormData({ ...formData, name: e.target.value })} placeholder="Enter business name" required />
setFormData({ ...formData, contactPerson: e.target.value })} placeholder="Primary contact name" />
setFormData({ ...formData, email: e.target.value })} placeholder="client@example.com" />
setFormData({ ...formData, phone: e.target.value })} placeholder="(555) 123-4567" />