web-humas-fe/services/activity-log.ts

37 lines
1.1 KiB
TypeScript

import { PaginationRequest } from "@/types/globals";
import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
export async function saveActivity(data: any, token?: string) {
const headers = token
? {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
}
: {
"content-type": "application/json",
};
const pathUrl = `/activity-logs`;
return await httpPost(pathUrl, headers, data);
}
export async function getActivity() {
const headers = { "content-type": "application/json" };
const pathUrl = `/activity-logs/statistics`;
return await httpGet(pathUrl, headers);
}
export async function getVisitorLog(data: any) {
const { page, limit, startDate, endDate } = data;
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
const pathUrl = `/activity-logs?purpose=visitor-summary&page=${
page || 0
}&limit=${limit || 10}&startDate=${startDate || ""}&endDate=${endDate || ""}`;
return await httpGet(pathUrl, headers);
}