import { memo, } from 'react' import { RiDeleteBinLine, RiDownloadLine, } from '@remixicon/react' import FileTypeIcon from '../file-type-icon' import { fileIsUploaded, getFileAppearanceType, getFileExtension, } from '../utils' import FileImageRender from '../file-image-render' import type { FileEntity } from '../types' import ActionButton from '@/app/components/base/action-button' import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' import { formatFileSize } from '@/utils/format' import cn from '@/utils/classnames' import { ReplayLine } from '@/app/components/base/icons/src/vender/other' import { SupportUploadFileTypes } from '@/app/components/workflow/types' type FileInAttachmentItemProps = { file: FileEntity showDeleteAction?: boolean showDownloadAction?: boolean onRemove?: (fileId: string) => void onReUpload?: (fileId: string) => void } const FileInAttachmentItem = ({ file, showDeleteAction, showDownloadAction = true, onRemove, onReUpload, }: FileInAttachmentItemProps) => { const { id, name, type, progress, supportFileType, base64Url, url, isRemote } = file const ext = getFileExtension(name, type, isRemote) const isImageFile = supportFileType === SupportUploadFileTypes.image return (
{ isImageFile && ( ) } { !isImageFile && ( ) }
{name}
{ ext && ( {ext.toLowerCase()} ) } { ext && ( ) } { !!file.size && ( {formatFileSize(file.size)} ) }
{ progress >= 0 && !fileIsUploaded(file) && ( ) } { progress === -1 && ( onReUpload?.(id)} > ) } { showDeleteAction && ( onRemove?.(id)}> ) } { showDownloadAction && ( ) }
) } export default memo(FileInAttachmentItem)