import React, { useState } from "react"; import { Card, Stack, Text, Group, Badge, Button, Box, Image, ThemeIcon, ActionIcon, Tooltip } from "@mantine/core"; import { useTranslation } from "react-i18next"; import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf"; import StorageIcon from "@mui/icons-material/Storage"; import VisibilityIcon from "@mui/icons-material/Visibility"; import EditIcon from "@mui/icons-material/Edit"; import { getFileSize, getFileDate } from "../../utils/fileUtils"; import { useIndexedDBThumbnail } from "../../hooks/useIndexedDBThumbnail"; import { fileStorage } from "../../services/fileStorage"; interface FileCardProps { file: FileWithUrl; onRemove: () => void; onDoubleClick?: () => void; onView?: () => void; onEdit?: () => void; isSelected?: boolean; onSelect?: () => void; } const FileCard = ({ file, onRemove, onDoubleClick, onView, onEdit, isSelected, onSelect }: FileCardProps) => { const { t } = useTranslation(); const { thumbnail: thumb, isGenerating } = useIndexedDBThumbnail(file); const [isHovered, setIsHovered] = useState(false); return ( setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} onClick={onSelect} > {/* Hover action buttons */} {isHovered && (onView || onEdit) && (
e.stopPropagation()} > {onView && ( { e.stopPropagation(); onView(); }} > )} {onEdit && ( { e.stopPropagation(); onEdit(); }} > )}
)} {thumb ? ( PDF thumbnail ) : isGenerating ? (
Generating...
) : (
100 * 1024 * 1024 ? "orange" : "red"} size={60} radius="sm" style={{ display: "flex", alignItems: "center", justifyContent: "center" }} > {file.size > 100 * 1024 * 1024 && ( Large File )}
)} {file.name} {getFileSize(file)} {getFileDate(file)} {file.storedInIndexedDB && ( } > DB )} ); }; export default FileCard;