quivr/frontend/lib/helpers/getFileIcon.tsx
Antoine Dewez b5e2d5ad9c
feat(frontend): Add Brain On Search Page (#2067)
# Description

- Implement Icon Component
- Implement TextButton Component
- Change Add Brain Button And Set it in the Search Page
- Fix Errors When sending empty message
- Change EsLint rules

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-01-22 17:37:45 -08:00

55 lines
1.3 KiB
TypeScript

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";
import { SupportedFileExtensions } from "../types/SupportedFileExtensions";
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,
telegram: BsFiletypeDocx,
};
export const getFileIcon = (fileName: string): JSX.Element => {
const fileType = getFileType(fileName);
const Icon = fileType !== undefined ? fileTypeIcons[fileType] : FaFile;
return <Icon className="text-2xl" />;
};