"use client"; import React, { useState, useEffect, useRef } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { api } from "~/trpc/react"; import { Button } from "~/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; import { Input } from "~/components/ui/input"; import { NumberInput } from "~/components/ui/number-input"; import { Label } from "~/components/ui/label"; import { Textarea } from "~/components/ui/textarea"; import { PageHeader } from "~/components/layout/page-header"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "~/components/ui/select"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "~/components/ui/alert-dialog"; import { Badge } from "~/components/ui/badge"; import { Separator } from "~/components/ui/separator"; import { DatePicker } from "~/components/ui/date-picker"; import { FloatingActionBar } from "~/components/layout/floating-action-bar"; import { toast } from "sonner"; import { ArrowLeft, Save, Plus, Trash2, FileText, Building, User, Loader2, Send, DollarSign, Hash, Edit3, } from "lucide-react"; interface InvoiceItem { tempId: string; date: Date; description: string; hours: number; rate: number; amount: number; } interface InvoiceFormData { invoiceNumber: string; businessId: string | undefined; clientId: string; issueDate: Date; dueDate: Date; notes: string; taxRate: number; items: InvoiceItem[]; } function InvoiceItemCard({ item, index, onUpdate, onDelete, _isLast, }: { item: InvoiceItem; index: number; onUpdate: ( index: number, field: keyof InvoiceItem, value: string | number | Date, ) => void; onDelete: (index: number) => void; _isLast: boolean; }) { const handleFieldChange = ( field: keyof InvoiceItem, value: string | number | Date, ) => { onUpdate(index, field, value); }; return (
{/* Header with item number and delete */}
Item {index + 1} Delete Item Are you sure you want to delete this line item? This action cannot be undone. Cancel onDelete(index)} className="bg-red-600 hover:bg-red-700" > Delete
{/* Description */}