Skip to content

Commit

Permalink
Refactor function postion
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Nov 11, 2024
1 parent 86df124 commit 024fc3e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions assets/js/pages/UpgradablePackagesPage/UpgradablePackages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ import Input from '@common/Input';
import Button from '@common/Button';
import { containsSubstring } from '@lib/filter';

const sortCsvContent = (content, sortingDirection) => {
if (content.length <= 1) {
return content;
}

return content.sort((packageA, packageB) => {
const comparison = packageA.latest_package.localeCompare(
packageB.latest_package
);
return sortingDirection === 'asc' ? comparison : -comparison;
});
};

export default function UpgradablePackages({
hostName,
upgradablePackages,
Expand Down Expand Up @@ -65,19 +78,6 @@ export default function UpgradablePackages({
}
);

const sortCsvContent = (content, sortingDirection) => {
if (content.length <= 1) {
return content;
}

return content.sort((packageA, packageB) => {
const comparison = packageA.latest_package.localeCompare(
packageB.latest_package
);
return sortingDirection === 'asc' ? comparison : -comparison;
});
};

useEffect(() => {
// Ensure to revoke previous csvUrls
if (csvURL) {
Expand Down

0 comments on commit 024fc3e

Please sign in to comment.