mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-12 02:39:17 +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";
|
||||
|
||||
const sortCategories = (categories: Category[]) => {
|
||||
const sortedCategories = categories.sort((a, b) => {
|
||||
return categories.sort((a, b) => {
|
||||
if (a.name === "Proxmox VE Tools") {
|
||||
return -1;
|
||||
} else if (b.name === "Proxmox VE Tools") {
|
||||
@ -14,13 +14,10 @@ const sortCategories = (categories: Category[]) => {
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
});
|
||||
|
||||
return sortedCategories;
|
||||
};
|
||||
|
||||
export const fetchCategories = async () => {
|
||||
const categories = await fetch(`api/categories`).then((response) =>
|
||||
response.json(),
|
||||
);
|
||||
export const fetchCategories = async (): Promise<Category[]> => {
|
||||
const response = await fetch("api/categories");
|
||||
const categories = await response.json();
|
||||
return sortCategories(categories);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user