diff --git a/src/app/quickaction-dashboard/register-sign-contract/company/page.tsx b/src/app/quickaction-dashboard/register-sign-contract/company/page.tsx index 56c8799..a7af1e5 100644 --- a/src/app/quickaction-dashboard/register-sign-contract/company/page.tsx +++ b/src/app/quickaction-dashboard/register-sign-contract/company/page.tsx @@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation' import PageLayout from '../../../components/PageLayout' import useAuthStore from '../../../store/authStore' import { useUserStatus } from '../../../hooks/useUserStatus' +import { API_BASE_URL } from '../../../utils/api' export default function CompanySignContractPage() { const router = useRouter() @@ -23,11 +24,43 @@ export default function CompanySignContractPage() { const [submitting, setSubmitting] = useState(false) const [success, setSuccess] = useState(false) const [error, setError] = useState('') + const [previewLoading, setPreviewLoading] = useState(false) + const [previewHtml, setPreviewHtml] = useState(null) + const [previewError, setPreviewError] = useState(null) useEffect(() => { setDate(new Date().toISOString().slice(0,10)) }, []) + // Load latest contract preview for company user + useEffect(() => { + const loadPreview = async () => { + if (!accessToken) return + setPreviewLoading(true) + setPreviewError(null) + try { + const res = await fetch(`${API_BASE_URL}/api/contracts/preview/latest`, { + method: 'GET', + headers: { Authorization: `Bearer ${accessToken}` }, + credentials: 'include' + }) + if (!res.ok) { + const text = await res.text().catch(() => '') + throw new Error(text || 'Failed to load contract preview') + } + const html = await res.text() + setPreviewHtml(html) + } catch (e: any) { + console.error('CompanySignContractPage.loadPreview error:', e) + setPreviewError(e?.message || 'Failed to load contract preview') + setPreviewHtml(null) + } finally { + setPreviewLoading(false) + } + } + loadPreview() + }, [accessToken]) + const valid = () => { const companyValid = companyName.trim().length >= 3 // Min 3 characters for company name const repNameValid = repName.trim().length >= 3 // Min 3 characters for representative name @@ -183,14 +216,63 @@ export default function CompanySignContractPage() {
-
-

- (Vertragsvorschau / PDF Platzhalter) -
Company Contract PDF would render here. -

-
- Scroll preview (disabled in mock) +
+
+

Vertragsvorschau (Unternehmen)

+
+ + +
+ {previewLoading ? ( +
Lade Vorschau…
+ ) : previewError ? ( +
{previewError}
+ ) : previewHtml ? ( +