web-humas-fe/services/master-categories.tsx

57 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-01-19 16:13:06 +00:00
import {
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
export async function createCategory(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
const pathUrl = `/article-categories`;
return await httpPost(pathUrl, headers, data);
}
export async function updateCategory(id: string, data: any) {
const headers = {
"content-type": "application/json",
2025-08-29 06:43:53 +00:00
Authorization: `Bearer ${token}`,
2025-01-19 16:13:06 +00:00
};
const pathUrl = `/article-categories/${id}`;
return await httpPut(pathUrl, headers, data);
}
export async function getCategoryById(id: number) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/article-categories/${id}`, headers);
}
2025-06-11 09:38:29 +00:00
// export async function deleteCategory(id: number) {
// const headers = {
// "content-type": "application/json",
// };
// return await httpDeleteInterceptor(`article-categories/${id}`, headers);
// }
2025-01-19 16:13:06 +00:00
export async function deleteCategory(id: number) {
2025-03-18 08:30:18 +00:00
const headers = {
"content-type": "application/json",
2025-08-29 06:43:53 +00:00
Authorization: `Bearer ${token}`,
2025-03-18 08:30:18 +00:00
};
2025-06-11 09:38:29 +00:00
return await httpPut(`article-categories/delete/${id}`, headers);
2025-01-19 16:13:06 +00:00
}
export async function uploadCategoryThumbnail(id: string, data: any) {
const headers = {
"content-type": "multipart/form-data",
2025-08-29 06:43:53 +00:00
Authorization: `Bearer ${token}`,
2025-01-19 16:13:06 +00:00
};
return await httpPost(`/article-categories/thumbnail/${id}`, headers, data);
}