update createApi

This commit is contained in:
Mohamadzadeh 2026-06-15 18:37:00 +03:30
parent 45a618f315
commit 51fb0695b7
2 changed files with 26 additions and 26 deletions

50
dist/index.js vendored
View File

@ -1,7 +1,7 @@
import { t as Z, a as w } from "./chunks/Pagination-LRiUo8_9.js"; 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 { P as ht, b as mt } from "./chunks/Pagination-LRiUo8_9.js";
import { jsxs as D, jsx as u } from "react/jsx-runtime"; 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 { 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 { IoChevronForwardOutline as J, IoChevronBackOutline as k } from "react-icons/io5";
import le from "keycloak-js"; 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( 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 (i) => i >= 1 && i <= t
); );
x(() => { y(() => {
if (C !== null) { if (C !== null) {
e === C && (d(null), s(!1), A(Z(e))); e === C && (d(null), s(!1), A(Z(e)));
return; return;
} }
o || A(Z(e)); o || A(Z(e));
}, [e, o, C]), x(() => { }, [e, o, C]), y(() => {
if (!o || !l || C !== null) return; if (!o || !l || C !== null) return;
const i = parseInt(w(l), 10); const i = parseInt(w(l), 10);
if (isNaN(i)) return; if (isNaN(i)) return;
@ -147,13 +147,13 @@ const At = ({
totalCount: n, totalCount: n,
onPageChange: r 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) => { (m) => {
const E = Math.min(Math.max(m, 1), t); const E = Math.min(Math.max(m, 1), t);
s(!1), A(""), d(null), E !== e && r(E); s(!1), A(""), d(null), E !== e && r(E);
}, },
[e, t, r] [e, t, r]
), i = y(() => { ), i = x(() => {
if (!l) { if (!l) {
s(!1), A(""), d(null); s(!1), A(""), d(null);
return; return;
@ -166,12 +166,12 @@ const At = ({
const E = Math.min(Math.max(m, 1), t); const E = Math.min(Math.max(m, 1), t);
s(!1), A(""), E !== e ? (d(E), r(E)) : d(null); s(!1), A(""), E !== e ? (d(E), r(E)) : d(null);
}, [l, e, t, r]); }, [l, e, t, r]);
x(() => { y(() => {
var m; var m;
o && ((m = p.current) == null || m.focus()); o && ((m = p.current) == null || m.focus());
}, [o]), x(() => { }, [o]), y(() => {
C !== null && e === C && d(null); C !== null && e === C && d(null);
}, [e, C]), x(() => { }, [e, C]), y(() => {
if (!o || !l) return; if (!o || !l) return;
const m = setTimeout(() => { const m = setTimeout(() => {
i(); i();
@ -290,17 +290,17 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
initOptions: n, initOptions: n,
loading: r = null 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)); 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)); p.current && (s(!!g), d((c == null ? void 0 : c.token) ?? null), A(!0));
}).catch(() => { }).catch(() => {
p.current && (s(!1), d(null), A(!0)); p.current && (s(!1), d(null), A(!0));
}), () => { }), () => {
p.current = !1; p.current = !1;
}), [t, n]); }), [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) => { async (g = 30) => {
if (!c) return !1; if (!c) return !1;
const S = await c.updateToken(g); 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( const A = Se(n), [o, s] = F(
() => Fe(A) () => Fe(A)
), { data: C, isLoading: d, error: p } = we(n), b = C ?? o; ), { data: C, isLoading: d, error: p } = we(n), b = C ?? o;
x(() => { y(() => {
C && (xe(A, C), s(C)); C && (ye(A, C), s(C));
}, [C, A]); }, [C, A]);
const h = M( const h = M(
() => ye(b), () => xe(b),
[b] [b]
), i = y( ), i = x(
(g = "") => De(h, g), (g = "") => De(h, g),
[h] [h]
), I = y((g = "") => !i(g), [i]), a = M( ), I = x((g = "") => !i(g), [i]), a = M(
() => ({ () => ({
user: e, user: e,
can: i, can: i,
@ -358,7 +358,7 @@ const pe = G(null), be = ({ url: e, realm: t, clientId: n }) => (c || (c = new l
} catch { } catch {
return; return;
} }
}, xe = (e = v, t) => { }, ye = (e = v, t) => {
if (!(typeof window > "u")) if (!(typeof window > "u"))
try { try {
localStorage.setItem(e, JSON.stringify(t)); 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); localStorage.removeItem(e);
} catch { } 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 (!t) return !1;
if (e.has(t) || [...e].some((r) => r.startsWith(t))) return !0; if (e.has(t) || [...e].some((r) => r.startsWith(t))) return !0;
let n = t; 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; return n && t("admin") ? e : null;
}, at = ({ children: e }) => { }, at = ({ children: e }) => {
const { can: t, isLoading: n } = R(); const { can: t, isLoading: n } = R();
return x(() => { return y(() => {
n || t("panel_access") || j(); n || t("panel_access") || j();
}, [n, t]), e; }, [n, t]), e;
}; };
@ -525,7 +525,7 @@ function gt({
return ce({ return ce({
mutationKey: [...A, d], mutationKey: [...A, d],
mutationFn: async (i = {}) => { 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; return (I === "delete" ? await r.delete(a, { data: g }) : await r[I](a, g)).data;
}, },
onSuccess: (...i) => { onSuccess: (...i) => {
@ -551,7 +551,7 @@ function gt({
} }
function Ne() { function Ne() {
const [e, t] = F(!1), n = q(null); const [e, t] = F(!1), n = q(null);
return x(() => { return y(() => {
if (process.env.NODE_ENV !== "production") return; if (process.env.NODE_ENV !== "production") return;
let r; let r;
const l = async () => { const l = async () => {
@ -681,9 +681,9 @@ function Ct({
r r
] ]
); );
if (x(() => { if (y(() => {
i(!0); i(!0);
}, []), x(() => { }, []), y(() => {
h && fe(g); h && fe(g);
}, [h, g]), !h) }, [h, g]), !h)
return null; return null;
@ -781,7 +781,7 @@ export {
lt as clearCachedPermissions, lt as clearCachedPermissions,
fe as configureApi, fe as configureApi,
gt as createApi, gt as createApi,
ye as createPermissionSet, xe as createPermissionSet,
Ye as fetcher, Ye as fetcher,
Me as getApi, Me as getApi,
Fe as getCachedPermissions, Fe as getCachedPermissions,
@ -793,7 +793,7 @@ export {
dt as loginKeycloak, dt as loginKeycloak,
j as logoutKeycloak, j as logoutKeycloak,
ee as permissionKeys, ee as permissionKeys,
xe as setCachedPermissions, ye as setCachedPermissions,
w as toEnDigits, w as toEnDigits,
Z as toFaDigits, Z as toFaDigits,
mt as toFaNumber, mt as toFaNumber,

View File

@ -77,7 +77,7 @@ export function createApi({
const payload = action.body const payload = action.body
? action.body(data) ? action.body(data)
: action.withId : action.sendRawPayload
? data ? data
: omitId(data); : omitId(data);