jaecoo-cihampelas/service/banner.ts

94 lines
2.3 KiB
TypeScript
Raw Permalink 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 getBannerData(props: PaginationRequest) {
const { page, limit, search } = props;
return await httpGetInterceptor(`/banners`);
}
export async function getBannerById(id: any) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/banners/${id}`, headers);
}
// export async function createBanner(data: any) {
// const pathUrl = `/banners`;
// return await httpPostInterceptor(pathUrl, data);
// }
export async function createBanner(data: any) {
const headers = {
"content-type": "multipart/form-data",
};
return await httpPostInterceptor(`/banners`, data, headers);
}
export async function updateBanner(data: any, id: any) {
const headers = {
"content-type": "multipart/form-data",
};
return await httpPutInterceptor(`/banners/${id}`, data, headers);
}
// export async function updateBanner(data: any, id: any) {
// const pathUrl = `/banners/${id}`;
// return await httpPutInterceptor(pathUrl, data);
// }
export async function deleteBanner(id: string) {
const headers = {
"content-type": "application/json",
};
return await httpDeleteInterceptor(`banners/${id}`, headers);
}
export async function approveBanner(id: string | number) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(`/banners/${id}/approve`, {}, headers);
}
export async function rejectBanner(id: string | number, message?: string) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(
`/banners/${id}/reject`,
{ message },
headers,
);
}
2026-01-26 03:04:14 +00:00
export async function commentBanner(id: string | number, message?: string) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(
`/banners/${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,
);
}