This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
breakpilot-pwa/admin-v2/components/sdk/academy/CertificateViewer.tsx
BreakPilot Dev ac1bb1d97b
Some checks failed
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
ci/woodpecker/push/integration Pipeline failed
ci/woodpecker/push/main Pipeline failed
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
feat: Implement Compliance Academy E-Learning module (Phases 1-7)
Add complete Academy backend (Go) and frontend (Next.js) for DSGVO/IT-Security/AI-Literacy compliance training:
- Go backend: Course CRUD, enrollments, quiz evaluation, PDF certificates (gofpdf), video generation pipeline (ElevenLabs + HeyGen)
- In-memory data store with PostgreSQL migration for future DB support
- Frontend: Course creation (AI + manual), lesson viewer, interactive quiz, certificate viewer with PDF download
- Fix existing compile errors in generate.go (SearchResult type mismatch), llm/service.go (unused var), rag/service.go (Unicode chars)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:18:51 +01:00

142 lines
5.3 KiB
TypeScript

'use client'
import { useState } from 'react'
import { Certificate } from '@/lib/sdk/academy/types'
import { downloadCertificatePDF } from '@/lib/sdk/academy/api'
interface CertificateViewerProps {
certificate: Certificate
onClose?: () => void
}
export default function CertificateViewer({ certificate, onClose }: CertificateViewerProps) {
const [downloading, setDownloading] = useState(false)
const [error, setError] = useState<string | null>(null)
const handleDownloadPDF = async () => {
setDownloading(true)
setError(null)
try {
const blob = await downloadCertificatePDF(certificate.id)
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `zertifikat-${certificate.id.slice(0, 8)}.pdf`
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
} catch (err) {
setError(err instanceof Error ? err.message : 'PDF-Download fehlgeschlagen')
} finally {
setDownloading(false)
}
}
const issuedDate = new Date(certificate.issuedAt).toLocaleDateString('de-DE', {
day: '2-digit', month: '2-digit', year: 'numeric'
})
const validDate = new Date(certificate.validUntil).toLocaleDateString('de-DE', {
day: '2-digit', month: '2-digit', year: 'numeric'
})
const isExpired = new Date(certificate.validUntil) < new Date()
return (
<div className="bg-white border border-gray-200 rounded-xl shadow-lg overflow-hidden">
{/* Certificate Preview */}
<div className="relative bg-gradient-to-br from-indigo-50 via-white to-purple-50 p-8">
{/* Decorative border */}
<div className="absolute inset-4 border-2 border-indigo-200 rounded-lg pointer-events-none" />
<div className="absolute inset-5 border border-indigo-100 rounded-lg pointer-events-none" />
<div className="relative text-center space-y-4">
{/* Company */}
<p className="text-sm text-gray-400 tracking-widest uppercase">BreakPilot Compliance</p>
{/* Title */}
<h2 className="text-2xl font-bold text-gray-900 tracking-wide">SCHULUNGSZERTIFIKAT</h2>
{/* Decorative line */}
<div className="mx-auto w-24 h-0.5 bg-indigo-500" />
{/* Body */}
<p className="text-sm text-gray-500">Hiermit wird bescheinigt, dass</p>
<p className="text-xl font-bold text-gray-900">{certificate.userName}</p>
<p className="text-sm text-gray-500">die folgende Compliance-Schulung erfolgreich abgeschlossen hat:</p>
<p className="text-lg font-semibold text-indigo-600">{certificate.courseName}</p>
{/* Score */}
{certificate.score > 0 && (
<p className="text-sm text-gray-500">
Testergebnis: <span className="font-semibold text-gray-700">{certificate.score}%</span>
</p>
)}
{/* Dates */}
<div className="flex justify-between items-center px-8 pt-4 text-xs text-gray-400">
<span>Abschlussdatum: {issuedDate}</span>
<span className={isExpired ? 'text-red-500 font-medium' : ''}>
Gueltig bis: {validDate}
{isExpired && ' (abgelaufen)'}
</span>
</div>
{/* Certificate ID */}
<p className="text-xs text-gray-300">
Zertifikats-Nr.: {certificate.id.slice(0, 12)}
</p>
</div>
</div>
{/* Actions */}
<div className="px-6 py-4 bg-gray-50 border-t border-gray-200 flex items-center justify-between">
<div className="text-xs text-gray-400">
Elektronisch erstellt - ohne Unterschrift gueltig
</div>
<div className="flex gap-3">
{onClose && (
<button
onClick={onClose}
className="px-4 py-2 text-sm text-gray-600 hover:text-gray-800 transition-colors"
>
Schliessen
</button>
)}
<button
onClick={handleDownloadPDF}
disabled={downloading}
className="px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 disabled:bg-indigo-400 rounded-lg transition-colors flex items-center gap-2"
>
{downloading ? (
<>
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" />
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
Wird erstellt...
</>
) : (
<>
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
PDF herunterladen
</>
)}
</button>
</div>
</div>
{/* Error */}
{error && (
<div className="px-6 py-3 bg-red-50 border-t border-red-200 text-sm text-red-600">
{error}
</div>
)}
</div>
)
}