web-humas-fe/services/feedbacks.ts

47 lines
1.2 KiB
TypeScript

import {
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
const token = Cookies.get("access_token");
export async function createFeedback(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
const pathUrl = `/feedbacks`;
return await httpPost(pathUrl, headers, data);
}
export async function getFeedbacks(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/feedbacks?page=${data?.page || 1}limit=${
data?.limit || ""
}&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${
data.endDate || ""
}`;
return await httpGetInterceptor(pathUrl);
}
export async function getFeedbacksById(id: number) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/feedbacks/${id}`;
return await httpGet(pathUrl, headers);
}
export async function deleteFeedback(id: number) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
return await httpDeleteInterceptor(`/feedbacks/${id}`, headers);
}