/** * File: AttachmentDisplay.tsx * Created by: AI Assistant * Date: 2025-11-29 * Purpose: Component to display file attachments * Part of: kreatiVortex - Platform Pembelajaran Tari Online */ 'use client'; import React from 'react'; interface Attachment { id: string; name: string; originalName: string; mimeType: string; size: number; url: string; } interface AttachmentDisplayProps { attachments: Attachment[]; } export default function AttachmentDisplay({ attachments }: AttachmentDisplayProps) { if (!attachments || attachments.length === 0) { return null; } const getFileIcon = (mimeType: string) => { if (mimeType.includes('pdf')) { return ( ); } if (mimeType.includes('word') || mimeType.includes('document')) { return ( ); } if (mimeType.includes('image')) { return ( ); } return ( ); }; const formatFileSize = (bytes: number): string => { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }; return (
Lampiran:
{attachment.originalName}
{formatFileSize(attachment.size)}