jaecoo-cihampelas/service/promotion.ts

82 lines
2.0 KiB
TypeScript
Raw Normal View History

2026-01-07 08:06:07 +00:00
import { PaginationRequest } from "@/types/globals";
import {
httpDeleteInterceptor,
httpGetInterceptor,
httpPostInterceptor,
httpPutInterceptor,
} from "./http-config/http-interceptor-services";
import { httpGet } from "./http-config/http-base-services";
export async function getPromotionPagination(props: PaginationRequest) {
const { page, limit, search } = props;
return await httpGetInterceptor(`/promotions`);
}
export async function getPromotionById(id: any) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/promotions/${id}`, headers);
}
export async function createPromotion(data: any) {
const headers = {
"content-type": "multipart/form-data",
};
return await httpPostInterceptor(`/promotions`, data, headers);
}
export async function updatePromotion(data: any, id: any) {
const pathUrl = `/promotions/${id}`;
return await httpPutInterceptor(pathUrl, data);
}
export async function deletePromotion(id: string) {
const headers = {
"content-type": "application/json",
};
return await httpDeleteInterceptor(`promotions/${id}`, headers);
}
export async function approvePromotion(id: string | number) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(`/promotions/${id}/approve`, {}, headers);
}
export async function rejectPromotion(id: string | number, message?: string) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(
`/promotions/${id}/reject`,
{ message },
headers,
);
}
export async function getApprovalHistory(
moduleType: string,
moduleId: string | number,
) {
const headers = {
"content-type": "application/json",
};
return await httpGet(
`/approval-histories/${moduleType}/${moduleId}`,
headers,
);
}
2026-01-26 07:42:55 +00:00
export async function commentPromotion(id: string | number, message?: string) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(
`/promotions/${id}/comment`,
{ message },
headers,
);
}