web-humas-fe/service/advertisement.ts

40 lines
1.1 KiB
TypeScript

import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
export async function createAdvertise(data: any) {
const headers = {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
};
const pathUrl = `/advertisement`;
return await httpPost(pathUrl, headers, data);
}
export async function getAdvertise(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${
data?.limit || ""
}&placement=${data?.placement || ""}`;
return await httpGet(pathUrl, headers);
}
export async function createAdvertiseById(id: number) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/advertisement/${id}`;
return await httpGet(pathUrl, headers);
}
export async function editAdvertise(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/advertisement/${data?.id}`;
return await httpPut(pathUrl, headers, data);
}