update createApi
This commit is contained in:
parent
45a618f315
commit
51fb0695b7
50
dist/index.js
vendored
50
dist/index.js
vendored
@ -1,7 +1,7 @@
|
||||
import { t as Z, a as w } from "./chunks/Pagination-LRiUo8_9.js";
|
||||
import { P as ht, b as mt } from "./chunks/Pagination-LRiUo8_9.js";
|
||||
import { jsxs as D, jsx as u } from "react/jsx-runtime";
|
||||
import { useState as F, useRef as q, useEffect as x, useCallback as y, createContext as G, useMemo as M, useContext as oe } from "react";
|
||||
import { useState as F, useRef as q, useEffect as y, useCallback as x, createContext as G, useMemo as M, useContext as oe } from "react";
|
||||
import { HStack as z, IconButton as Y, Button as V, Input as U, Text as T, extendTheme as ie, withDefaultColorScheme as re, ChakraProvider as Ae, Spinner as se, Box as de, VStack as L, Image as P } from "@chakra-ui/react";
|
||||
import { IoChevronForwardOutline as J, IoChevronBackOutline as k } from "react-icons/io5";
|
||||
import le from "keycloak-js";
|
||||
@ -17,13 +17,13 @@ const At = ({
|
||||
const [l, A] = F(Z(e)), [o, s] = F(!1), [C, d] = F(null), p = q(null), b = [.../* @__PURE__ */ new Set([1, e, t])].filter(
|
||||
(i) => i >= 1 && i <= t
|
||||
);
|
||||
x(() => {
|
||||
y(() => {
|
||||
if (C !== null) {
|
||||
e === C && (d(null), s(!1), A(Z(e)));
|
||||
return;
|
||||
}
|
||||
o || A(Z(e));
|
||||
}, [e, o, C]), x(() => {
|
||||
}, [e, o, C]), y(() => {
|
||||
if (!o || !l || C !== null) return;
|
||||
const i = parseInt(w(l), 10);
|
||||
if (isNaN(i)) return;
|
||||
@ -147,13 +147,13 @@ const At = ({
|
||||
totalCount: n,
|
||||
onPageChange: r
|
||||
}) => {
|
||||
const [l, A] = F(""), [o, s] = F(!1), [C, d] = F(null), p = q(null), b = C ?? e, h = y(
|
||||
const [l, A] = F(""), [o, s] = F(!1), [C, d] = F(null), p = q(null), b = C ?? e, h = x(
|
||||
(m) => {
|
||||
const E = Math.min(Math.max(m, 1), t);
|
||||
s(!1), A(""), d(null), E !== e && r(E);
|
||||
},
|
||||
[e, t, r]
|
||||
), i = y(() => {
|
||||
), i = x(() => {
|
||||
if (!l) {
|
||||
s(!1), A(""), d(null);
|
||||
return;
|
||||
@ -166,12 +166,12 @@ const At = ({
|
||||
const E = Math.min(Math.max(m, 1), t);
|
||||
s(!1), A(""), E !== e ? (d(E), r(E)) : d(null);
|
||||
}, [l, e, t, r]);
|
||||
x(() => {
|
||||
y(() => {
|
||||
var m;
|
||||
o && ((m = p.current) == null || m.focus());
|
||||
}, [o]), x(() => {
|
||||
}, [o]), y(() => {
|
||||
C !== null && e === C && d(null);
|
||||
}, [e, C]), x(() => {
|
||||
}, [e, C]), y(() => {
|
||||
if (!o || !l) return;
|
||||
const m = setTimeout(() => {
|
||||
i();
|
||||
@ -290,17 +290,17 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
|
||||
initOptions: n,
|
||||
loading: r = null
|
||||
}) => {
|
||||
const [l, A] = F(!1), [o, s] = F(!1), [C, d] = F(null), p = q(!1), b = y(() => {
|
||||
const [l, A] = F(!1), [o, s] = F(!1), [C, d] = F(null), p = q(!1), b = x(() => {
|
||||
c && (s(!!c.authenticated), d(c.token ?? null));
|
||||
}, []);
|
||||
x(() => (p.current = !0, _({ config: t, initOptions: n }).then((g) => {
|
||||
y(() => (p.current = !0, _({ config: t, initOptions: n }).then((g) => {
|
||||
p.current && (s(!!g), d((c == null ? void 0 : c.token) ?? null), A(!0));
|
||||
}).catch(() => {
|
||||
p.current && (s(!1), d(null), A(!0));
|
||||
}), () => {
|
||||
p.current = !1;
|
||||
}), [t, n]);
|
||||
const h = y(() => c == null ? void 0 : c.login(), []), i = y((g) => c == null ? void 0 : c.logout(g), []), I = y(
|
||||
const h = x(() => c == null ? void 0 : c.login(), []), i = x((g) => c == null ? void 0 : c.logout(g), []), I = x(
|
||||
async (g = 30) => {
|
||||
if (!c) return !1;
|
||||
const S = await c.updateToken(g);
|
||||
@ -329,16 +329,16 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
|
||||
const A = Se(n), [o, s] = F(
|
||||
() => Fe(A)
|
||||
), { data: C, isLoading: d, error: p } = we(n), b = C ?? o;
|
||||
x(() => {
|
||||
C && (xe(A, C), s(C));
|
||||
y(() => {
|
||||
C && (ye(A, C), s(C));
|
||||
}, [C, A]);
|
||||
const h = M(
|
||||
() => ye(b),
|
||||
() => xe(b),
|
||||
[b]
|
||||
), i = y(
|
||||
), i = x(
|
||||
(g = "") => De(h, g),
|
||||
[h]
|
||||
), I = y((g = "") => !i(g), [i]), a = M(
|
||||
), I = x((g = "") => !i(g), [i]), a = M(
|
||||
() => ({
|
||||
user: e,
|
||||
can: i,
|
||||
@ -358,7 +358,7 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}, xe = (e = v, t) => {
|
||||
}, ye = (e = v, t) => {
|
||||
if (!(typeof window > "u"))
|
||||
try {
|
||||
localStorage.setItem(e, JSON.stringify(t));
|
||||
@ -370,7 +370,7 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
|
||||
localStorage.removeItem(e);
|
||||
} catch {
|
||||
}
|
||||
}, ye = (e) => e ? new Set(e.map((t) => t.name)) : /* @__PURE__ */ new Set(), De = (e, t = "") => {
|
||||
}, xe = (e) => e ? new Set(e.map((t) => t.name)) : /* @__PURE__ */ new Set(), De = (e, t = "") => {
|
||||
if (!t) return !1;
|
||||
if (e.has(t) || [...e].some((r) => r.startsWith(t))) return !0;
|
||||
let n = t;
|
||||
@ -418,7 +418,7 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
|
||||
return n && t("admin") ? e : null;
|
||||
}, at = ({ children: e }) => {
|
||||
const { can: t, isLoading: n } = R();
|
||||
return x(() => {
|
||||
return y(() => {
|
||||
n || t("panel_access") || j();
|
||||
}, [n, t]), e;
|
||||
};
|
||||
@ -525,7 +525,7 @@ function gt({
|
||||
return ce({
|
||||
mutationKey: [...A, d],
|
||||
mutationFn: async (i = {}) => {
|
||||
const I = h.method || "post", a = We(h.url, i), g = h.body ? h.body(i) : h.withId ? i : Xe(i);
|
||||
const I = h.method || "post", a = We(h.url, i), g = h.body ? h.body(i) : h.sendRawPayload ? i : Xe(i);
|
||||
return (I === "delete" ? await r.delete(a, { data: g }) : await r[I](a, g)).data;
|
||||
},
|
||||
onSuccess: (...i) => {
|
||||
@ -551,7 +551,7 @@ function gt({
|
||||
}
|
||||
function Ne() {
|
||||
const [e, t] = F(!1), n = q(null);
|
||||
return x(() => {
|
||||
return y(() => {
|
||||
if (process.env.NODE_ENV !== "production") return;
|
||||
let r;
|
||||
const l = async () => {
|
||||
@ -681,9 +681,9 @@ function Ct({
|
||||
r
|
||||
]
|
||||
);
|
||||
if (x(() => {
|
||||
if (y(() => {
|
||||
i(!0);
|
||||
}, []), x(() => {
|
||||
}, []), y(() => {
|
||||
h && fe(g);
|
||||
}, [h, g]), !h)
|
||||
return null;
|
||||
@ -781,7 +781,7 @@ export {
|
||||
lt as clearCachedPermissions,
|
||||
fe as configureApi,
|
||||
gt as createApi,
|
||||
ye as createPermissionSet,
|
||||
xe as createPermissionSet,
|
||||
Ye as fetcher,
|
||||
Me as getApi,
|
||||
Fe as getCachedPermissions,
|
||||
@ -793,7 +793,7 @@ export {
|
||||
dt as loginKeycloak,
|
||||
j as logoutKeycloak,
|
||||
ee as permissionKeys,
|
||||
xe as setCachedPermissions,
|
||||
ye as setCachedPermissions,
|
||||
w as toEnDigits,
|
||||
Z as toFaDigits,
|
||||
mt as toFaNumber,
|
||||
|
||||
@ -77,7 +77,7 @@ export function createApi({
|
||||
|
||||
const payload = action.body
|
||||
? action.body(data)
|
||||
: action.withId
|
||||
: action.sendRawPayload
|
||||
? data
|
||||
: omitId(data);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user