diff options
Diffstat (limited to 'src/wwwroot/scripts/api/categories-api.ts')
| -rw-r--r-- | src/wwwroot/scripts/api/categories-api.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/wwwroot/scripts/api/categories-api.ts b/src/wwwroot/scripts/api/categories-api.ts new file mode 100644 index 0000000..1ca1d97 --- /dev/null +++ b/src/wwwroot/scripts/api/categories-api.ts @@ -0,0 +1,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"); +}
\ No newline at end of file |
