import React from 'react'; import { useAuth } from '../../contexts/AuthContext'; import type { Snippet } from '../../types'; import CodeBlock from '../common/CodeBlock'; interface SnippetViewerProps { snippet: Snippet; onEdit: () => void; onDelete: () => void; } const SnippetViewer: React.FC = ({ snippet, onEdit, onDelete }) => { const { user } = useAuth(); const isOwner = user?.id === snippet.owner_id; const copyToClipboard = () => { navigator.clipboard.writeText(snippet.content); alert('Copied to clipboard!'); }; return (

{snippet.title}

Language: {snippet.language} Visibility: {snippet.visibility} By: {snippet.owner_username}
{snippet.tags && (
{snippet.tags.split(',').map((tag, i) => ( {tag.trim()} ))}
)}
{isOwner && (
)}
Created: {new Date(snippet.created_at).toLocaleString()}
Updated: {new Date(snippet.updated_at).toLocaleString()}
); }; export default SnippetViewer;