diff --git a/src/pages/BillApprovalsPage.tsx b/src/pages/BillApprovalsPage.tsx index 51c6e87..c38fe0f 100644 --- a/src/pages/BillApprovalsPage.tsx +++ b/src/pages/BillApprovalsPage.tsx @@ -3,7 +3,7 @@ import { useNavigate } from "react-router-dom"; import { supabase } from "@/integrations/supabase/client"; import { useToast } from "@/hooks/use-toast"; import { useAuth } from "@/contexts/AuthContext"; -import { UserCheck, Plus, Search, Eye, Upload, X, ArrowUpDown, Edit, Trash2, MoreHorizontal, AlertTriangle, Loader2, Bell, Printer, Sparkles, Download } from "lucide-react"; +import { UserCheck, Plus, Search, Eye, Upload, X, ArrowUpDown, Edit, Trash2, MoreHorizontal, AlertTriangle, Loader2, Bell, Printer, Sparkles, Download, FileText, Save } from "lucide-react"; import { generateCheckPDF, type CheckData } from "@/pages/accounting/lib/checkPdf"; import { accounting } from "@/lib/accountingClient"; import { Alert, AlertDescription } from "@/components/ui/alert"; @@ -99,6 +99,68 @@ export default function BillApprovalsPage({ boardAssociationIds }: { boardAssoci const [uploadFile, setUploadFile] = useState(null); const [submitting, setSubmitting] = useState(false); const fileRef = useRef(null); + const [filePreview, setFilePreview] = useState(null); + const [dragOver, setDragOver] = useState(false); + useEffect(() => { + if (uploadFile && uploadFile.type.startsWith("image/")) { + const url = URL.createObjectURL(uploadFile); + setFilePreview(url); + return () => URL.revokeObjectURL(url); + } + setFilePreview(null); + }, [uploadFile]); + const handleFile = (f: File) => setUploadFile(f); + + // Buildium-style left attachment panel, shared by the Create and Edit dialogs. + const renderAttachmentPanel = (existingUrl?: string | null) => { + const isPdf = (existingUrl || "").toLowerCase().endsWith(".pdf"); + const empty = !filePreview && !uploadFile && !existingUrl; + return ( +
{ e.preventDefault(); setDragOver(true); }} + onDragLeave={() => setDragOver(false)} + onDrop={(e) => { e.preventDefault(); setDragOver(false); const f = e.dataTransfer.files?.[0]; if (f) handleFile(f); }} + className={`relative rounded-lg border-2 border-dashed min-h-[420px] flex flex-col items-center justify-center text-center p-6 transition-colors ${dragOver ? "border-primary bg-primary/5" : "border-border"} ${empty ? "cursor-pointer hover:bg-muted/40" : ""}`} + onClick={() => { if (empty) fileRef.current?.click(); }} + > + { const f = e.target.files?.[0]; if (f) handleFile(f); }} /> + {filePreview ? ( + Attachment + ) : uploadFile ? ( +
+ +
{uploadFile.name}
+
{(uploadFile.size / 1024).toFixed(1)} KB
+
+ ) : existingUrl ? ( + isPdf ? ( +