import React, { useEffect, useState } from 'react'; import { Award, CheckCircle, QrCode, Building, User, Calendar, Hash } from 'lucide-react'; import QRCode from 'qrcode'; import { useOrg } from '@components/Contexts/OrgContext'; import { getOrgLogoMediaDirectory } from '@services/media/media'; interface CertificatePreviewProps { certificationName: string; certificationDescription: string; certificationType: string; certificatePattern: string; certificateInstructor?: string; } const CertificatePreview: React.FC = ({ certificationName, certificationDescription, certificationType, certificatePattern, certificateInstructor }) => { const [qrCodeUrl, setQrCodeUrl] = useState(''); const org = useOrg() as any; // Generate QR code useEffect(() => { const generateQRCode = async () => { try { const certificateData = `https://learnhouse.app/verify/LH-2024-001`; const qrUrl = await QRCode.toDataURL(certificateData, { width: 185, margin: 1, color: { dark: '#000000', light: '#FFFFFF' }, errorCorrectionLevel: 'M', type: 'image/png' }); setQrCodeUrl(qrUrl); } catch (error) { console.error('Error generating QR code:', error); } }; generateQRCode(); }, []); // Function to get theme colors for each pattern const getPatternTheme = (pattern: string) => { switch (pattern) { case 'royal': return { primary: 'text-amber-700', secondary: 'text-amber-600', icon: 'text-amber-600', badge: 'bg-amber-50 text-amber-700 border-amber-200' }; case 'tech': return { primary: 'text-cyan-700', secondary: 'text-cyan-600', icon: 'text-cyan-600', badge: 'bg-cyan-50 text-cyan-700 border-cyan-200' }; case 'nature': return { primary: 'text-green-700', secondary: 'text-green-600', icon: 'text-green-600', badge: 'bg-green-50 text-green-700 border-green-200' }; case 'geometric': return { primary: 'text-purple-700', secondary: 'text-purple-600', icon: 'text-purple-600', badge: 'bg-purple-50 text-purple-700 border-purple-200' }; case 'vintage': return { primary: 'text-orange-700', secondary: 'text-orange-600', icon: 'text-orange-600', badge: 'bg-orange-50 text-orange-700 border-orange-200' }; case 'waves': return { primary: 'text-blue-700', secondary: 'text-blue-600', icon: 'text-blue-600', badge: 'bg-blue-50 text-blue-700 border-blue-200' }; case 'minimal': return { primary: 'text-gray-700', secondary: 'text-gray-600', icon: 'text-gray-600', badge: 'bg-gray-50 text-gray-700 border-gray-200' }; case 'professional': return { primary: 'text-slate-700', secondary: 'text-slate-600', icon: 'text-slate-600', badge: 'bg-slate-50 text-slate-700 border-slate-200' }; case 'academic': return { primary: 'text-indigo-700', secondary: 'text-indigo-600', icon: 'text-indigo-600', badge: 'bg-indigo-50 text-indigo-700 border-indigo-200' }; case 'modern': return { primary: 'text-blue-700', secondary: 'text-blue-600', icon: 'text-blue-600', badge: 'bg-blue-50 text-blue-700 border-blue-200' }; default: return { primary: 'text-gray-700', secondary: 'text-gray-600', icon: 'text-gray-600', badge: 'bg-gray-50 text-gray-700 border-gray-200' }; } }; // Function to render different certificate patterns const renderCertificatePattern = (pattern: string) => { switch (pattern) { case 'royal': return ( <> {/* Royal ornate border with crown elements */}
{/* Crown-like decorations in corners */}
{/* Royal background pattern */}
); case 'tech': return ( <> {/* Tech circuit board borders */}
{/* Circuit-like corner elements */}
{/* Tech grid background */}
); case 'nature': return ( <> {/* Nature organic border */}
{/* Leaf-like decorations */}
{/* Organic background pattern */}
); case 'geometric': return ( <> {/* Geometric angular borders */}
{/* Geometric corner elements */}
{/* Abstract geometric shapes */}
{/* Geometric background */}
); case 'vintage': return ( <> {/* Art deco style borders */}
{/* Art deco corner decorations */}
{/* Art deco sunburst pattern */}
); case 'waves': return ( <> {/* Flowing wave borders */}
{/* Wave decorations */}
{/* Side wave patterns */}
{/* Wave background */}
); case 'minimal': return ( <> {/* Minimal clean border */}
{/* Subtle corner accents */}
); case 'professional': return ( <> {/* Professional double border */}
{/* Professional corner brackets */}
{/* Subtle professional background */}
); case 'academic': return ( <> {/* Academic traditional border */}
{/* Academic shield-like corners */}
{/* Academic laurel-like decorations */}
{/* Academic background pattern */}
); case 'modern': return ( <> {/* Modern clean asymmetric border */}
{/* Modern accent lines */}
{/* Modern dot accents */}
{/* Modern subtle background */}
); default: return null; } }; const theme = getPatternTheme(certificatePattern); return (
{/* Dynamic Certificate Pattern */} {renderCertificatePattern(certificatePattern)} {/* Certificate ID - Top Left */}
ID: LH-2024-001
{/* QR Code Box - Top Right */}
{qrCodeUrl ? ( Certificate QR Code ) : (
)}
{/* Main Content */}
{/* Header with decorative line */}
Certificate
{/* Award Icon with decorative elements */}
{/* Decorative rays */}
{/* Certificate Content */}

{certificationName || 'Certification Name'}

{certificationDescription || 'Certification description will appear here...'}

{/* Decorative divider */}
{/* Certification Type Badge */}
{certificationType === 'completion' ? 'Course Completion' : certificationType === 'achievement' ? 'Achievement Based' : certificationType === 'assessment' ? 'Assessment Based' : certificationType === 'participation' ? 'Participation' : certificationType === 'mastery' ? 'Skill Mastery' : certificationType === 'professional' ? 'Professional Development' : certificationType === 'continuing' ? 'Continuing Education' : certificationType === 'workshop' ? 'Workshop Attendance' : certificationType === 'specialization' ? 'Specialization' : 'Course Completion'}
{/* Bottom Section */}
{/* Left: Teacher/Organization Signature */}
Instructor
{certificateInstructor || 'Dr. Jane Smith'}
{/* Center: Logo */}
{org?.logo_image ? ( Organization Logo ) : (
)}
{org?.name || 'LearnHouse'}
{/* Right: Award Date */}
Awarded
Dec 15, 2024
); }; export default CertificatePreview;