jaecoo-kelapagading/service/agent.ts

73 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-11-18 06:56:39 +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 getAgentData(props: PaginationRequest) {
const { page, limit, search } = props;
return await httpGetInterceptor(`/sales-agents`);
}
export async function getAgentById(id: any) {
const headers = {
"content-type": "application/json",
};
return await httpGet(`/sales-agents/${id}`, headers);
}
export async function createAgent(data: any) {
2025-11-20 06:57:16 +00:00
const headers = {
"content-type": "multipart/form-data",
};
return await httpPostInterceptor(`/sales-agents`, data, headers);
2025-11-18 06:56:39 +00:00
}
export async function updateAgent(id: number, data: any) {
2025-11-20 06:57:16 +00:00
const headers = {
"content-type": "multipart/form-data",
};
return await httpPutInterceptor(`/sales-agents/${id}`, data, headers);
2025-11-18 06:56:39 +00:00
}
export async function deleteAgent(id: string) {
const headers = {
"content-type": "application/json",
};
return await httpDeleteInterceptor(`sales-agents/${id}`, headers);
}
2026-01-20 01:04:42 +00:00
export async function approveAgent(id: string | number) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(`/sales-agents/${id}/approve`, {}, headers);
2026-01-20 03:35:33 +00:00
}
export async function rejectAgent(id: string | number, message?: string) {
const headers = {
"content-type": "application/json",
};
return await httpPutInterceptor(
`/sales-agents/${id}/reject`,
{ message },
headers,
);
2026-01-20 03:35:33 +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",
};
return await httpGet(
`/approval-histories/${moduleType}/${moduleId}`,
headers,
);
}