diff --git a/src/components/client/irregularity/helpers/FileList.tsx b/src/components/client/irregularity/helpers/FileList.tsx index 2755affd7..60cce893a 100644 --- a/src/components/client/irregularity/helpers/FileList.tsx +++ b/src/components/client/irregularity/helpers/FileList.tsx @@ -1,7 +1,17 @@ import React from 'react' import { Delete, UploadFile } from '@mui/icons-material' -import { Avatar, IconButton, List, ListItem, ListItemAvatar, ListItemText } from '@mui/material' +import { + Avatar, + IconButton, + List, + ListItem, + ListItemAvatar, + ListItemText, + Tooltip, +} from '@mui/material' + +import { formatFileName } from './formatFileName' type Props = { files: File[] @@ -24,8 +34,10 @@ function FileList({ files, onDelete }: Props) { - - + + + + ))} diff --git a/src/components/client/irregularity/helpers/formatFileName.ts b/src/components/client/irregularity/helpers/formatFileName.ts new file mode 100644 index 000000000..37d875e77 --- /dev/null +++ b/src/components/client/irregularity/helpers/formatFileName.ts @@ -0,0 +1,12 @@ +export const formatFileName = (fileName: string) => { + const maxLength = 15 + if (fileName.length <= maxLength) return fileName + + const fileExtension = fileName.split('.').pop() + if (fileExtension) { + const nameWithoutExtension = fileName.slice(0, -(fileExtension.length + 1)) + return `${nameWithoutExtension.slice(0, 6)}...${nameWithoutExtension.slice( + -6, + )}.${fileExtension}` + } +} diff --git a/src/components/client/irregularity/steps/Info.tsx b/src/components/client/irregularity/steps/Info.tsx index 873dc92c7..0f3074be9 100644 --- a/src/components/client/irregularity/steps/Info.tsx +++ b/src/components/client/irregularity/steps/Info.tsx @@ -12,6 +12,7 @@ import Subtitle from '../helpers/Subtitle' import FileList from '../helpers/FileList' import { NotifierTypes } from '../helpers/irregularity.types' import IrregularityReasonSelect from '../helpers/IrregularityReasonSelect' +import { Box } from '@mui/material' import theme from 'common/theme' @@ -103,21 +104,28 @@ export default function Info({ files, setFiles }: Props) { {t('steps.info.files')} - + { setFiles((prevFiles: File[]) => [...prevFiles, ...newFiles]) }} buttonLabel={t('cta.upload-files')} /> - - setFiles((prevFiles: File[]) => - prevFiles.filter((file: File) => file.name !== deletedFile.name), - ) - } - /> + + + setFiles((prevFiles: File[]) => + prevFiles.filter((file: File) => file.name !== deletedFile.name), + ) + } + /> +