Skip to content

Commit e4ac7b2

Browse files
authored
Add getStudentName display-name util (#235)
Composes a student's display name from firstName + lastName, handling trimming and single-name fallback once instead of per call site. Closes #234
1 parent 3edb0ae commit e4ac7b2

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/lib/getStudentName.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const getStudentName = (student: { firstName?: string; lastName?: string }): string =>
2+
[student.firstName, student.lastName]
3+
.map((part) => part?.trim())
4+
.filter(Boolean)
5+
.join(' ')

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './utils'
22
export * from './formatFileSize'
33
export * from './getCountries'
44
export * from './getGravatarUrl'
5+
export * from './getStudentName'
56
export * from './getStatusBadge'
67
export * from './getStatusColor'
78
export * from './openFileDownload'

0 commit comments

Comments
 (0)