aboutsummaryrefslogtreecommitdiffstats
path: root/src/wwwroot/scripts/api/categories-api.ts
blob: 1ca1d97b00d6354548b0e389d28bacf9524080d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export function getCategories(withProducts: boolean = false): Promise<Response> {
    return fetch(withProducts ? "/api/categories/with-products" : "/api/categories");
}

export function getCategory(categoryId: string): Promise<Response> {
    return fetch("/api/categories/" + categoryId);
}

export function createCategory(name: string, disabled: boolean): Promise<Response> {
    return fetch("/api/categories/create?" + new URLSearchParams({
        name
    }));
}

export function updateCategory(categoryId: string, newName: string): Promise<Response> {
    return fetch("/api/categories/" + categoryId + "/update?" + new URLSearchParams({
        newName
    }));
}

export function deleteCategory(categoryId: string): Promise<Response> {
    return fetch("/api/categories/" + categoryId + "/delete", {
        method: "delete"
    });
}

export function enableCategory(categoryId: string): Promise<Response> {
    return fetch("/api/categories/" + categoryId + "/enable");
}

export function disableCategory(categoryId: string): Promise<Response> {
    return fetch("/api/categories/" + categoryId + "/disable");
}