Refactor: Move util function to proper folder
This commit is contained in:
parent
261d5d2af1
commit
9c19d5cdf1
2 changed files with 9 additions and 9 deletions
|
|
@ -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 (
|
||||
<div className="relative inline-block">
|
||||
{loading ? (
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue