mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-11-10 13:22:50 +00:00
24 lines
644 B
TypeScript
24 lines
644 B
TypeScript
|
|
import { Category } from "./types";
|
||
|
|
|
||
|
|
const sortCategories = (categories: Category[]) => {
|
||
|
|
return categories.sort((a, b) => {
|
||
|
|
if (a.name === "Proxmox VE Tools") {
|
||
|
|
return -1;
|
||
|
|
} else if (b.name === "Proxmox VE Tools") {
|
||
|
|
return 1;
|
||
|
|
} else if (a.name === "Miscellaneous") {
|
||
|
|
return 1;
|
||
|
|
} else if (b.name === "Miscellaneous") {
|
||
|
|
return -1;
|
||
|
|
} else {
|
||
|
|
return a.name.localeCompare(b.name);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
export const fetchCategories = async (): Promise<Category[]> => {
|
||
|
|
const response = await fetch("api/categories");
|
||
|
|
const categories = await response.json();
|
||
|
|
return sortCategories(categories);
|
||
|
|
};
|