From 9c19d5cdf1d0e3abdca4b0f0ec096ab2ebbe01a8 Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Wed, 29 May 2024 18:13:33 -0300 Subject: [PATCH] Refactor: Move util function to proper folder --- .../components/chatView/filePreviewChat/index.tsx | 10 +--------- .../filePreviewChat/utils/format-file-name.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/utils/format-file-name.tsx diff --git a/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx index 092a797f1..704efae0f 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/index.tsx @@ -2,6 +2,7 @@ import { useState } from "react"; import IconComponent, { ForwardedIconComponent, } from "../../../../../components/genericIconComponent"; +import formatFileName from "./utils/format-file-name"; export default function FilePreview({ error, @@ -18,15 +19,6 @@ export default function FilePreview({ const [isHovered, setIsHovered] = useState(false); - const formatFileName = (name) => { - const fileExtension = name.split(".").pop(); // Get the file extension - const baseName = name.slice(0, name.lastIndexOf(".")); // Get the base name without the extension - if (baseName.length > 6) { - return `${baseName.slice(0, 29)}...${fileExtension}`; - } - return name; - }; - return (
{loading ? ( diff --git a/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/utils/format-file-name.tsx b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/utils/format-file-name.tsx new file mode 100644 index 000000000..0e8a23921 --- /dev/null +++ b/src/frontend/src/modals/IOModal/components/chatView/filePreviewChat/utils/format-file-name.tsx @@ -0,0 +1,8 @@ +export default function formatFileName(name: string): string { + const fileExtension = name.split(".").pop(); // Get the file extension + const baseName = name.slice(0, name.lastIndexOf(".")); // Get the base name without the extension + if (baseName.length > 6) { + return `${baseName.slice(0, 29)}...${fileExtension}`; + } + return name; +}