import { FiX, FiFile, FiImage } from "react-icons/fi";
/**
* FileAttachmentPreview component - shows selected files before sending
*/
function FileAttachmentPreview({ files, onRemove, isDark }) {
if (!files || files.length === 0) return null;
const handleRemove = (index) => {
if (onRemove) {
onRemove(index);
}
};
return (
{files.map((file, index) => (
{file.type?.startsWith("image/") ? (
) : (
{file.type === "application/pdf" ? (
) : (
)}
)}
{file.name}
{formatFileSize(file.size)}
))}
);
}
/**
* Format file size to human-readable format
*/
function formatFileSize(bytes) {
if (!bytes || bytes === 0) return "0 B";
const k = 1024;
const sizes = ["B", "KB", "MB", "GB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
}
export default FileAttachmentPreview;