import React from 'react'; import Image from 'next/image'; import { MaterialDTO, MaterialType, UserDTO } from '../types'; import { Code, Video, Package, Heart, Download, Eye, Terminal } from 'lucide-react'; interface MaterialCardProps { material: MaterialDTO; onClick: (id: string) => void; currentUser?: UserDTO | null; } export const MaterialCard: React.FC = ({ material, onClick, currentUser }) => { const Icon = material.type === MaterialType.CODE ? Code : material.type === MaterialType.VIDEO ? Video : Package; const typeColor = material.type === MaterialType.CODE ? 'text-cyber-blue' : material.type === MaterialType.VIDEO ? 'text-cyber-pink' : 'text-cyber-neon'; const borderColor = material.type === MaterialType.CODE ? 'hover:border-cyber-blue/50' : material.type === MaterialType.VIDEO ? 'hover:border-cyber-pink/50' : 'hover:border-cyber-neon/50'; // Check if current user has favorited this material const isFavorited = currentUser && material.favorites?.some(f => f.userId === currentUser.id); const siteIconSvg = encodeURIComponent( ``+ ``+ ``+ `NM`+ `` ); const authorAvatar = material.author.avatarUrl && material.author.avatarUrl.trim() ? material.author.avatarUrl : `data:image/svg+xml;utf8,${siteIconSvg}`; return (
onClick(material.id)} className={`group relative bg-cyber-panel/40 backdrop-blur-sm border border-white/5 ${borderColor} overflow-hidden cursor-pointer transition-all duration-500 hover:-translate-y-1 hover:shadow-2xl hover:shadow-cyber-neon/5`} > {/* Decoration Top Right */}
{/* Content Area */}
{material.type}
{material.language && (
.{material.language}
)}

{material.title}

{material.description}

{/* Preview (Code or Image placeholder) */}
{material.type === MaterialType.CODE ? (
{material.codeSnippet}
) : (
)}
{/* Footer Stats */}
{material.stats.views} {material.stats.favorites}
author {material.author.username}
{/* Hover Line Animation */}
); };