'use client' import React from 'react' interface Attachment { name: string | undefined url?: string contentType: string } interface AttachmentPreviewProps { attachments: Attachment[] } export const AttachmentPreview: React.FC = ({ attachments }) => { if (!attachments?.length) return null return (
{attachments.map((att, index) => { const isImage = att.contentType.startsWith('image/') const isPdf = att.contentType === 'application/pdf' const url = att.url return (
{!url ? (
{att.name ?? 'File'} unavailable
) : isImage ? (
{/* eslint-disable-next-line @next/next/no-img-element */} {att.name
) : isPdf ? ( 📄 {att.name} ) : ( 📎 {att.name} )}
) })}
) }