diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx index 8e563f65..cea14f0a 100644 --- a/frontend/src/settings/Documents.tsx +++ b/frontend/src/settings/Documents.tsx @@ -15,6 +15,7 @@ import { Doc, DocumentsProps, ActiveState } from '../models/misc'; // Ensure Act import { getDocs, getDocsWithPagination } from '../preferences/preferenceApi'; import { setSourceDocs } from '../preferences/preferenceSlice'; import { setPaginatedDocuments } from '../preferences/preferenceSlice'; +import { truncate } from '../utils/stringUtils'; // Utility function to format numbers const formatTokens = (tokens: number): string => { @@ -134,7 +135,6 @@ const Documents: React.FC = ({ }; useEffect(() => { - // console.log('modalState', modalState); if (modalState === 'INACTIVE') { refreshDocs(sortField, currentPage, rowsPerPage); } @@ -184,13 +184,13 @@ const Documents: React.FC = ({
- +
- - - + className="px-6 py-2 text-start font-medium text-gray-700 dark:text-gray-50 uppercase" + > + {' '} + {!currentDocuments?.length && ( @@ -239,13 +244,16 @@ const Documents: React.FC = ({ {Array.isArray(currentDocuments) && currentDocuments.map((document, index) => ( - - -
+ {t('settings.documents.name')} +
{t('settings.documents.date')} = ({ />
+
{t('settings.documents.tokenUsage')} = ({ */}
{t('settings.documents.noData')}
- {document.name} + + {truncate(document.name, 50)} + {document.date} + {document.tokens ? formatTokens(+document.tokens) : ''} diff --git a/frontend/src/utils/stringUtils.ts b/frontend/src/utils/stringUtils.ts new file mode 100644 index 00000000..e87a7af3 --- /dev/null +++ b/frontend/src/utils/stringUtils.ts @@ -0,0 +1,4 @@ +export function truncate(str: string, n: number) { + // slices long strings and ends with ... + return str.length > n ? str.slice(0, n - 1) + '...' : str; +}