mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-14 11:49:16 +00:00
Update src/lib/data.ts with necessary changes.
Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com>
This commit is contained in:
parent
ada264ecb8
commit
e5c7df88a6
@ -1,7 +1,7 @@
|
|||||||
import { Category } from "./types";
|
import { Category } from "./types";
|
||||||
|
|
||||||
const sortCategories = (categories: Category[]) => {
|
const sortCategories = (categories: Category[]) => {
|
||||||
const sortedCategories = categories.sort((a, b) => {
|
return categories.sort((a, b) => {
|
||||||
if (a.name === "Proxmox VE Tools") {
|
if (a.name === "Proxmox VE Tools") {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (b.name === "Proxmox VE Tools") {
|
} else if (b.name === "Proxmox VE Tools") {
|
||||||
@ -14,13 +14,10 @@ const sortCategories = (categories: Category[]) => {
|
|||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return sortedCategories;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchCategories = async () => {
|
export const fetchCategories = async (): Promise<Category[]> => {
|
||||||
const categories = await fetch(`api/categories`).then((response) =>
|
const response = await fetch("api/categories");
|
||||||
response.json(),
|
const categories = await response.json();
|
||||||
);
|
|
||||||
return sortCategories(categories);
|
return sortCategories(categories);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user