Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
(components/team/teamBadges): Make sorting a param
Browse files Browse the repository at this point in the history
  • Loading branch information
jcxldn committed Jun 23, 2023
1 parent eee603d commit 2ccedf1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/team/teamBadges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const tagColors = {
leaders: "primary",
};

export type TeamBadgesProps = { tags: TeamTagColourNode[] };
export type TeamBadgesProps = { tags: TeamTagColourNode[], sortAlphabetically?: boolean };

interface TeamBadgesState {
isReady: boolean;
Expand All @@ -63,10 +63,13 @@ export class TeamBadges extends React.Component<TeamBadgesProps, TeamBadgesState
// Tags is sometimes empty. problem upstream.
componentDidMount(): void {
if (this.props.tags) {
// Sort tags alphabetically by tag name
this.props.tags.sort((a, b) => {
return a.tag.localeCompare(b.tag);
});

if (this.props.sortAlphabetically) {
// Sort tags alphabetically by tag name
this.props.tags.sort((a, b) => {
return a.tag.localeCompare(b.tag);
});
}

// Iterate over each tag and construct a badge.
this.props.tags.forEach(tag => {
Expand Down

0 comments on commit 2ccedf1

Please sign in to comment.