72 lines
2.1 KiB
TypeScript
72 lines
2.1 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 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);
|
|
}
|
|
|
|
export async function getApprovalHistory(moduleType: string, moduleId: string | number) {
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return await httpGetInterceptor(`/approval-histories/${moduleType}/${moduleId}`, headers);
|
|
} |