'use client'; import { useState } from 'react'; import { Button } from '@/components/ui/Button'; import { getContractDownloadUrl, regenerateContract } from '@/lib/sales'; interface ContractPreviewProps { saleId: string; contractPdfPath?: string | null; } export function ContractPreview({ saleId, contractPdfPath }: ContractPreviewProps) { const [regenerating, setRegenerating] = useState(false); const [error, setError] = useState(null); const [pdfPath, setPdfPath] = useState(contractPdfPath || null); const handleRegenerate = async () => { setRegenerating(true); setError(null); try { const result = await regenerateContract(saleId); setPdfPath(result.contract_pdf_path); } catch (err: unknown) { const apiErr = err as { error?: { message?: string } }; setError(apiErr?.error?.message || 'Failed to regenerate contract'); } finally { setRegenerating(false); } }; const downloadUrl = getContractDownloadUrl(saleId); return (

Vertrags-PDF

{pdfPath && ( )}
{error && (
{error}
)} {pdfPath ? (