From 9383a2fb09ffb60cfe63683106945bd688affa59 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 1 Jun 2022 21:13:43 +0200 Subject: feat: Initial commit after clean slate --- src/wwwroot/scripts/api/categories-api.ts | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/wwwroot/scripts/api/categories-api.ts (limited to 'src/wwwroot/scripts/api/categories-api.ts') 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 { + return fetch(withProducts ? "/api/categories/with-products" : "/api/categories"); +} + +export function getCategory(categoryId: string): Promise { + return fetch("/api/categories/" + categoryId); +} + +export function createCategory(name: string, disabled: boolean): Promise { + return fetch("/api/categories/create?" + new URLSearchParams({ + name + })); +} + +export function updateCategory(categoryId: string, newName: string): Promise { + return fetch("/api/categories/" + categoryId + "/update?" + new URLSearchParams({ + newName + })); +} + +export function deleteCategory(categoryId: string): Promise { + return fetch("/api/categories/" + categoryId + "/delete", { + method: "delete" + }); +} + +export function enableCategory(categoryId: string): Promise { + return fetch("/api/categories/" + categoryId + "/enable"); +} + +export function disableCategory(categoryId: string): Promise { + return fetch("/api/categories/" + categoryId + "/disable"); +} \ No newline at end of file -- cgit v1.3