Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Platzer <[email protected]>
  • Loading branch information
yushinj and EjPlatzer authored Jun 13, 2024
1 parent 06b2b18 commit 1b9fb91
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/services/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@ const categorizeItems = async (memberships: MembershipHistory[], jobs: StudentEm

groupedMembershipHistory.activities = memberships;

/**
* Sorting job titles by alphabetical order.
* Sorting job titles by end date if there are the same job titles.
*/
groupedMembershipHistory.experiences.sort((a, b) =>
getJobTitle(a).localeCompare(getJobTitle(b)) !== 0
? getJobTitle(a).localeCompare(getJobTitle(b))
: getExperienceEndDate(b) - getExperienceEndDate(a),
);
// Sort experiences by experience name then by end date
groupedMembershipHistory.experiences.sort((a, b) => {
const nameComparison = getName(a).localeCompare(getName(b));
return nameComparison !== 0
? nameComparison
: getExperienceEndDate(b) - getExperienceEndDate(a);
});

return groupedMembershipHistory;
};
Expand Down Expand Up @@ -148,5 +146,5 @@ const transcriptService = {

export default transcriptService;

const getJobTitle = (experience: MembershipHistory | StudentEmployment) =>
const getName = (experience: MembershipHistory | StudentEmployment) =>
'Sessions' in experience ? experience.ActivityCode : experience.Job_Title;

0 comments on commit 1b9fb91

Please sign in to comment.