2025-11-18 06:56:39 +00:00
|
|
|
import { PaginationRequest } from "@/types/globals";
|
|
|
|
|
import {
|
|
|
|
|
httpDeleteInterceptor,
|
|
|
|
|
httpGetInterceptor,
|
|
|
|
|
httpPostInterceptor,
|
|
|
|
|
httpPutInterceptor,
|
|
|
|
|
} from "./http-config/http-interceptor-services";
|
2026-01-19 11:25:14 +00:00
|
|
|
import { httpGet } from "./http-config/http-base-services";
|
2025-11-18 06:56:39 +00:00
|
|
|
|
|
|
|
|
export async function getProductPagination(props: PaginationRequest) {
|
|
|
|
|
const { page, limit, search } = props;
|
|
|
|
|
return await httpGetInterceptor(`/products`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// export async function createProduct(data: any) {
|
|
|
|
|
// const pathUrl = `/products`;
|
|
|
|
|
// return await httpPostInterceptor(pathUrl, data);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
export async function createProduct(data: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "multipart/form-data",
|
|
|
|
|
};
|
|
|
|
|
return await httpPostInterceptor(`/products`, data, headers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateProduct(data: any, id: any) {
|
|
|
|
|
const pathUrl = `/products/${id}`;
|
2026-01-28 01:39:32 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "multipart/form-data",
|
|
|
|
|
};
|
|
|
|
|
return await httpPutInterceptor(pathUrl, data, headers);
|
2025-11-18 06:56:39 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-19 11:25:14 +00:00
|
|
|
export async function getProductDataById(id: any) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpGet(`/products/${id}`, headers);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 06:56:39 +00:00
|
|
|
export async function deleteProduct(id: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpDeleteInterceptor(`products/${id}`, headers);
|
|
|
|
|
}
|
2026-01-20 01:04:42 +00:00
|
|
|
|
|
|
|
|
export async function approveProduct(id: string | number) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpPutInterceptor(`/products/${id}/approve`, {}, headers);
|
2026-01-20 03:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function rejectProduct(id: string | number, message?: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
2026-01-20 09:22:45 +00:00
|
|
|
return await httpPutInterceptor(
|
|
|
|
|
`/products/${id}/reject`,
|
|
|
|
|
{ message },
|
|
|
|
|
headers,
|
|
|
|
|
);
|
2026-01-20 03:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-26 07:43:25 +00:00
|
|
|
export async function commentProduct(id: string | number, message?: string) {
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
return await httpPutInterceptor(
|
|
|
|
|
`/products/${id}/comment`,
|
|
|
|
|
{ message },
|
|
|
|
|
headers,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-20 09:22:45 +00:00
|
|
|
export async function getApprovalHistory(
|
|
|
|
|
moduleType: string,
|
|
|
|
|
moduleId: string | number,
|
|
|
|
|
) {
|
2026-01-20 03:35:33 +00:00
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
2026-01-20 09:22:45 +00:00
|
|
|
return await httpGet(
|
|
|
|
|
`/approval-histories/${moduleType}/${moduleId}`,
|
|
|
|
|
headers,
|
|
|
|
|
);
|
|
|
|
|
}
|