import React, { useState } from "react"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { FileText, Download, Upload, Save, X } from "lucide-react"; import { Badge } from "@/components/ui/badge"; export default function W9FormViewer({ vendor, onClose }) { const [formData, setFormData] = useState({ entity_name: vendor?.business_name || "", business_name: "", tax_classification: "", llc_classification: "", has_foreign_partners: false, exempt_payee_code: "", fatca_code: "", address: "", city_state_zip: "", account_numbers: "", ssn_part1: "", ssn_part2: "", ssn_part3: "", ein_part1: "", ein_part2: "", tin_type: "ssn", signature: "", date: "" }); const handleChange = (field, value) => { setFormData(prev => ({ ...prev, [field]: value })); }; const handleSave = () => { // Save logic here console.log("Saving W9 form:", formData); onClose?.(); }; return (
{/* Header with actions */}

Form W-9 (Rev. March 2024)

Request for Taxpayer Identification Number and Certification

{/* Before you begin notice */}

Before you begin

Give form to the requester. Do not send to the IRS.

{/* Line 1 & 2 - Names */}

For a sole proprietor or disregarded entity, enter the owner's name on line 1

handleChange('entity_name', e.target.value)} placeholder="Enter name as shown on your tax return" className="font-medium" />
handleChange('business_name', e.target.value)} placeholder="Enter business or DBA name (if applicable)" />
{/* Line 3a - Tax Classification */}
checked && handleChange('tax_classification', 'individual')} />
checked && handleChange('tax_classification', 'c_corp')} />
checked && handleChange('tax_classification', 's_corp')} />
checked && handleChange('tax_classification', 'partnership')} />
checked && handleChange('tax_classification', 'trust')} />
checked && handleChange('tax_classification', 'llc')} /> Enter tax classification: handleChange('llc_classification', e.target.value)} placeholder="C, S, or P" className="w-20 h-8" maxLength={1} />
checked && handleChange('tax_classification', 'other')} />
{/* Line 3b */}
handleChange('has_foreign_partners', checked)} />

Check if you have any foreign partners, owners, or beneficiaries

{/* Line 4 - Exemptions */}
handleChange('exempt_payee_code', e.target.value)} placeholder="See instructions" className="mt-1" />
handleChange('fatca_code', e.target.value)} placeholder="Applies to accounts outside US" className="mt-1" />
{/* Lines 5-7 - Address */}
handleChange('address', e.target.value)} placeholder="Enter street address" className="mt-1" />
handleChange('city_state_zip', e.target.value)} placeholder="City, State ZIP" className="mt-1" />
handleChange('account_numbers', e.target.value)} placeholder="Account numbers" className="mt-1" />
{/* Part I - TIN */}

Part I - Taxpayer Identification Number (TIN)

Enter your TIN in the appropriate box. The TIN provided must match the name given on line 1 to avoid backup withholding.

{/* SSN */}
handleChange('ssn_part1', e.target.value)} maxLength={3} placeholder="XXX" className="w-20 text-center font-mono" disabled={formData.tin_type === "ein"} /> handleChange('ssn_part2', e.target.value)} maxLength={2} placeholder="XX" className="w-16 text-center font-mono" disabled={formData.tin_type === "ein"} /> handleChange('ssn_part3', e.target.value)} maxLength={4} placeholder="XXXX" className="w-24 text-center font-mono" disabled={formData.tin_type === "ein"} />
OR
{/* EIN */}
handleChange('ein_part1', e.target.value)} maxLength={2} placeholder="XX" className="w-16 text-center font-mono" disabled={formData.tin_type === "ssn"} /> handleChange('ein_part2', e.target.value)} maxLength={7} placeholder="XXXXXXX" className="w-32 text-center font-mono" disabled={formData.tin_type === "ssn"} />
{/* Part II - Certification */}

Part II - Certification

Under penalties of perjury, I certify that:

  1. The number shown on this form is my correct taxpayer identification number (or I am waiting for a number to be issued to me); and
  2. I am not subject to backup withholding because (a) I am exempt from backup withholding, or (b) I have not been notified by the IRS that I am subject to backup withholding as a result of a failure to report all interest or dividends, or (c) the IRS has notified me that I am no longer subject to backup withholding; and
  3. I am a U.S. citizen or other U.S. person (defined below); and
  4. The FATCA code(s) entered on this form (if any) indicating that I am exempt from FATCA reporting is correct.
handleChange('signature', e.target.value)} placeholder="Sign here" className="mt-1 italic" />
handleChange('date', e.target.value)} className="mt-1" />
{/* Actions */}
Form W-9 (Rev. 3-2024)
); }