Skip to content

Commit

Permalink
fix: instructor formatting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Samathingamajig committed Nov 12, 2024
1 parent db04bbb commit 757a48d
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/shared/types/Instructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,33 @@ export default class Instructor {
return capitalize(str);
};

if (format === 'abbr' && firstName && lastName && firstName[0]) {
return `${process(firstName[0])}. ${process(lastName)}`;
}
if (format === 'full_name' && fullName) {
if (format === 'full_name') {
if (!fullName) {
return process(lastName || firstName || 'Unknown');
}
return process(fullName);
}
if (format === 'first_last' && firstName && lastName) {

// Avoid duplicating this for every remaining case
if (!lastName) {
return process(fullName || firstName || 'Unknown');
}

if (format === 'abbr') {
if (!firstName || !firstName[0]) {
return process(lastName);
}
return `${process(firstName[0])}. ${process(lastName)}`;
}

if (format === 'first_last') {
if (!firstName) {
return process(lastName);
}
return `${process(firstName)} ${process(lastName)}`;
}
if (format === 'last' && lastName) {

if (format === 'last') {
return process(lastName);
}

Expand Down

0 comments on commit 757a48d

Please sign in to comment.