@devgateway/dvz-ui-react
Version:
A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.
32 lines (31 loc) • 982 B
JavaScript
import "../../conf/index.js";
import { get as f } from "../../api/commons.js";
function c(t) {
return JSON.parse(JSON.stringify(t));
}
const i = process.env.VITE_REACT_APP_API_ROOT, r = {}, s = {}, p = 3 * 60 * 1e3;
function a(t) {
return Object.keys(t).map((e) => encodeURIComponent(e) + "=" + encodeURIComponent(t[e])).join("&");
}
function l(t) {
const e = t, n = Date.now();
if (s[e] && n - s[e].timestamp < p)
return Promise.resolve(c(s[e].data));
if (r[e])
return r[e].then(c);
const o = f(t).then((u) => (s[e] = { data: u, timestamp: Date.now() }, c(u))).finally(() => {
delete r[e];
});
return r[e] = o, o;
}
const O = ({ app: t, params: e }) => {
const n = `${i || ""}/api/${t}/categories${e ? "?" + a(e) : ""}`;
return console.log("categories==>", n), l(n);
}, R = ({ source: t, app: e, params: n }) => {
const o = `${i || ""}/api/${e}/stats/${t}${n ? "?" + a(n) : ""}`;
return l(o);
};
export {
O as getCategories,
R as getData
};