diff --git a/frontend/src/components/StudentProfile.tsx b/frontend/src/components/StudentProfile.tsx index fc6c8ee..8c8be01 100644 --- a/frontend/src/components/StudentProfile.tsx +++ b/frontend/src/components/StudentProfile.tsx @@ -176,6 +176,30 @@ export default function StudentProfile({ id }: StudentProfileProps) { setCurrentView(currentView === "View" ? "Edit" : "View"); }; + const TruncateDocument = ({ + documentName, + documentLength, + }: { + documentName: string; + documentLength: number; + }) => { + const minLength = 9; // Shortest truncation + const maxLength = 20; // Longest truncation + const baseName = documentName.slice(0, documentName.lastIndexOf(".")); + + // Use an inverse relationship: fewer documents = longer names + const dynamicLength = Math.max( + minLength, + Math.min(maxLength, 20 - Math.floor((documentLength - 1) * 2)), + ); + + // Only truncate and add ellipsis if the basename is longer than dynamicLength + const displayName = + baseName.length > dynamicLength ? baseName.substring(0, dynamicLength) + "..." : baseName; + + return displayName; + }; + const deleteStudentHandler: MouseEventHandler = () => { const lastName = getDeleteValue("lastname"); if (studentData && firebaseToken && studentData.student.lastName === lastName) { @@ -423,12 +447,24 @@ export default function StudentProfile({ id }: StudentProfileProps) {
Documents
- - + {studentData.documents?.map((doc, index) => ( + + ))}