import { useState } from 'react' import { RiCloseLine, RiDownloadLine, } from '@remixicon/react' import FileImageRender from '../file-image-render' import type { FileEntity } from '../types' import { downloadFile, fileIsUploaded, } from '../utils' import Button from '@/app/components/base/button' import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' import { ReplayLine } from '@/app/components/base/icons/src/vender/other' import ImagePreview from '@/app/components/base/image-uploader/image-preview' type FileImageItemProps = { file: FileEntity showDeleteAction?: boolean showDownloadAction?: boolean canPreview?: boolean onRemove?: (fileId: string) => void onReUpload?: (fileId: string) => void } const FileImageItem = ({ file, showDeleteAction, showDownloadAction, canPreview, onRemove, onReUpload, }: FileImageItemProps) => { const { id, progress, base64Url, url, name } = file const [imagePreviewUrl, setImagePreviewUrl] = useState('') return ( <>
canPreview && setImagePreviewUrl(url || '')} > { showDeleteAction && ( ) } { progress >= 0 && !fileIsUploaded(file) && (
) } { progress === -1 && (
onReUpload?.(id)} />
) } { showDownloadAction && (
{ e.stopPropagation() downloadFile(url || '', name) }} >
) }
{ imagePreviewUrl && canPreview && ( setImagePreviewUrl('')} /> ) } ) } export default FileImageItem