82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
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 commentPromotion(id: string | number, message?: string) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpPutInterceptor(
|
|
`/promotions/${id}/comment`,
|
|
{ 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,
|
|
);
|
|
}
|