51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
"use client";
|
|
import axios from "axios";
|
|
import Cookies from "js-cookie";
|
|
import qs from "qs";
|
|
|
|
import { data } from "@/app/[locale]/(protected)/charts/rechart/charts-rechart-bar/data";
|
|
import { url } from "inspector";
|
|
|
|
const baseURL = "https://netidhub.com/api/";
|
|
const tokenAuth = Cookies.get("access_token")
|
|
? Cookies.get("access_token")
|
|
: null;
|
|
import { getAPIInterceptor } from "@/config/api";
|
|
import axiosInterceptor from "@/config/axiosInterceptor";
|
|
|
|
export async function postAPIInterceptorTableau(url: string, data?: any) {
|
|
const response = await axiosInterceptor
|
|
.post(url, data)
|
|
.catch((error) => error.response);
|
|
|
|
if (response?.status === 401) {
|
|
Object.keys(Cookies.get()).forEach((cookieName) => {
|
|
Cookies.remove(cookieName);
|
|
});
|
|
window.location.href = "/";
|
|
} else if (response?.status > 300 && response?.status !== 401) {
|
|
return {
|
|
error: true,
|
|
message: response?.data?.message,
|
|
data: null,
|
|
};
|
|
} else if (response?.data?.success) {
|
|
return {
|
|
error: false,
|
|
message: "success",
|
|
data: response?.data,
|
|
};
|
|
}
|
|
|
|
return {
|
|
error: true,
|
|
message: response?.data?.message,
|
|
data: null,
|
|
};
|
|
}
|
|
|
|
export async function generateTicket() {
|
|
const url = "/admin/tableau-ticket";
|
|
return postAPIInterceptorTableau(url);
|
|
}
|