2023-09-07 11:00:45 +03:00
|
|
|
import {
|
|
|
|
BsFiletypeCsv,
|
|
|
|
BsFiletypeDocx,
|
|
|
|
BsFiletypeHtml,
|
|
|
|
BsFiletypeMd,
|
|
|
|
BsFiletypeMp3,
|
|
|
|
BsFiletypeMp4,
|
|
|
|
BsFiletypePdf,
|
|
|
|
BsFiletypePptx,
|
|
|
|
BsFiletypePy,
|
|
|
|
BsFiletypeTxt,
|
|
|
|
BsFiletypeXls,
|
|
|
|
BsFiletypeXlsx,
|
|
|
|
} from "react-icons/bs";
|
|
|
|
import { FaFile, FaRegFileAudio } from "react-icons/fa";
|
|
|
|
import { LiaFileVideo } from "react-icons/lia";
|
|
|
|
import { IconType } from "react-icons/lib";
|
|
|
|
|
|
|
|
import { getFileType } from "./getFileType";
|
2024-01-23 04:37:45 +03:00
|
|
|
|
2023-09-12 18:44:15 +03:00
|
|
|
import { SupportedFileExtensions } from "../types/SupportedFileExtensions";
|
2023-09-07 11:00:45 +03:00
|
|
|
|
|
|
|
const fileTypeIcons: Record<SupportedFileExtensions, IconType> = {
|
|
|
|
pdf: BsFiletypePdf,
|
|
|
|
mp3: BsFiletypeMp3,
|
|
|
|
mp4: BsFiletypeMp4,
|
|
|
|
html: BsFiletypeHtml,
|
|
|
|
txt: BsFiletypeTxt,
|
|
|
|
csv: BsFiletypeCsv,
|
|
|
|
md: BsFiletypeMd,
|
|
|
|
markdown: BsFiletypeMd,
|
|
|
|
m4a: LiaFileVideo,
|
|
|
|
mpga: FaRegFileAudio,
|
|
|
|
mpeg: LiaFileVideo,
|
|
|
|
webm: LiaFileVideo,
|
|
|
|
wav: FaRegFileAudio,
|
|
|
|
pptx: BsFiletypePptx,
|
|
|
|
docx: BsFiletypeDocx,
|
|
|
|
odt: BsFiletypeDocx,
|
|
|
|
xlsx: BsFiletypeXlsx,
|
|
|
|
xls: BsFiletypeXls,
|
|
|
|
epub: FaFile,
|
|
|
|
ipynb: BsFiletypePy,
|
|
|
|
py: BsFiletypePy,
|
2023-11-02 00:09:04 +03:00
|
|
|
telegram: BsFiletypeDocx,
|
2024-06-25 17:02:53 +03:00
|
|
|
bib: FaFile,
|
2023-09-07 11:00:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export const getFileIcon = (fileName: string): JSX.Element => {
|
|
|
|
const fileType = getFileType(fileName);
|
|
|
|
|
|
|
|
const Icon = fileType !== undefined ? fileTypeIcons[fileType] : FaFile;
|
|
|
|
|
2024-06-25 17:02:53 +03:00
|
|
|
return <Icon width={24} height={24} />;
|
2023-09-07 11:00:45 +03:00
|
|
|
};
|