File size: 685 Bytes
fb3b3ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import { getExtension } from '@/utils/document-util';
import SvgIcon from '../svg-icon';
import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
import styles from './index.less';
interface IProps {
name: string;
id: string;
}
const FileIcon = ({ name, id }: IProps) => {
const fileExtension = getExtension(name);
// TODO: replace this line with react query
const fileThumbnails = useSelectFileThumbnails();
const fileThumbnail = fileThumbnails[id];
return fileThumbnail ? (
<img src={fileThumbnail} className={styles.thumbnailImg}></img>
) : (
<SvgIcon name={`file-icon/${fileExtension}`} width={24}></SvgIcon>
);
};
export default FileIcon;
|