Skip to content

Commit

Permalink
chore:sort install repositories version dropdown
Browse files Browse the repository at this point in the history
- development should be the last option
- versions DESC
  • Loading branch information
nathan-vm committed Nov 27, 2023
1 parent 1b65f07 commit 374dd4b
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,26 @@ export const RepositoriesCard: FC = () => {
})
.then((data) => {
if (data) {
setAvailableVersions(data?.splice(0, 10));
const devVersion = data.find(
(item) =>
item.version === "dev" || item.version === "development",
);
const versionsOnly = data
.filter(
(item) =>
item.version !== "dev" && item.version !== "development",
)
.splice(0, 10);

const sortedVersions = versionsOnly.sort(
(a, b) => parseFloat(b.version) - parseFloat(a.version),
);

const sortedData = devVersion
? [...sortedVersions, devVersion]
: sortedVersions;

setAvailableVersions(sortedData);
}
setStep("SELECT_VERSION");
})
Expand Down

0 comments on commit 374dd4b

Please sign in to comment.