@lambda-development/erp-core 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +723 -698
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx as e, jsxs as r, Fragment as Ne } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState as N, useEffect as se, useCallback as ke, useContext as In, createContext as Ln, useRef as H, useMemo as Ce, useLayoutEffect as tn, StrictMode as sa } from "react";
|
|
3
3
|
import { createRoot as ia } from "react-dom/client";
|
|
4
4
|
import { useQueryClient as Qe, useQuery as oe, useMutation as ue, QueryClientProvider as oa, QueryClient as la } from "@tanstack/react-query";
|
|
5
|
-
import { NavLink as St, useLocation as
|
|
6
|
-
import { useTranslation as
|
|
5
|
+
import { NavLink as St, useLocation as mt, useNavigate as Oe, Outlet as ca, Navigate as da, Link as ye, useSearchParams as kt, useParams as pt, createBrowserRouter as ua, RouterProvider as ma } from "react-router-dom";
|
|
6
|
+
import { useTranslation as X, initReactI18next as pa } from "react-i18next";
|
|
7
7
|
import { BookOpen as ha, ShoppingCart as Bn, CreditCard as ga, FileText as Gt, Package as En, BarChart3 as ya, Database as fa, Settings as ba, MessageCircle as xa, ChevronDown as Wt, ChevronRight as Kt, Plus as On, Trash2 as qn, LineChart as va, TrendingUp as Na, ArrowDownRight as wa, ArrowUpRight as Sa, Wallet as ka, Receipt as nn } from "lucide-react";
|
|
8
8
|
import { createColumnHelper as zn, useReactTable as Fn, getCoreRowModel as Mn, flexRender as bt } from "@tanstack/react-table";
|
|
9
9
|
import { createPortal as Ca } from "react-dom";
|
|
@@ -182,13 +182,13 @@ const O = {
|
|
|
182
182
|
function Ea({ children: t }) {
|
|
183
183
|
const [n, a] = N(null), [s, o] = N(!0);
|
|
184
184
|
se(() => {
|
|
185
|
-
O.authMe().then((
|
|
185
|
+
O.authMe().then((g) => a(g)).catch(() => a(null)).finally(() => o(!1));
|
|
186
186
|
}, []);
|
|
187
|
-
const i = ke(async (
|
|
188
|
-
const
|
|
189
|
-
return a(
|
|
190
|
-
}, []), c = ke(async (
|
|
191
|
-
const x = await O.authRegister({ email:
|
|
187
|
+
const i = ke(async (g, d) => {
|
|
188
|
+
const p = await O.authLogin(g, d);
|
|
189
|
+
return a(p), p;
|
|
190
|
+
}, []), c = ke(async (g, d, p, m) => {
|
|
191
|
+
const x = await O.authRegister({ email: g, full_name: d, password: p, invite_token: m });
|
|
192
192
|
return a(x), x;
|
|
193
193
|
}, []), l = ke(async () => {
|
|
194
194
|
try {
|
|
@@ -199,7 +199,7 @@ function Ea({ children: t }) {
|
|
|
199
199
|
}, []);
|
|
200
200
|
return /* @__PURE__ */ e(Un.Provider, { value: { user: n, loading: s, login: i, register: c, logout: l }, children: t });
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function it() {
|
|
203
203
|
const t = In(Un);
|
|
204
204
|
if (!t) throw new Error("useAuth must be used within AuthProvider");
|
|
205
205
|
return t;
|
|
@@ -289,61 +289,61 @@ function Ve(t) {
|
|
|
289
289
|
return Number.isNaN(a) ? 0 : a;
|
|
290
290
|
}
|
|
291
291
|
function za({ children: t }) {
|
|
292
|
-
const n = Qe(), [a, s] = N([]), [o, i] = N({}), [c, l] = N({}), [
|
|
293
|
-
function R(
|
|
292
|
+
const n = Qe(), [a, s] = N([]), [o, i] = N({}), [c, l] = N({}), [g, d] = N({}), [p, m] = N({}), [x, C] = N({}), [b, f] = N({}), [_, A] = N({}), [q, u] = N(null), [h, D] = N("connecting"), [k, w] = N(0), W = H(null), v = H(null), I = H(/* @__PURE__ */ new Map()), z = H(null), V = H({}), ee = H({}), de = H(null);
|
|
293
|
+
function R(S) {
|
|
294
294
|
for (const j of I.current.values())
|
|
295
|
-
j.reject(new Error(
|
|
295
|
+
j.reject(new Error(S));
|
|
296
296
|
I.current.clear();
|
|
297
297
|
}
|
|
298
|
-
function K(
|
|
298
|
+
function K(S, j) {
|
|
299
299
|
i((G) => ({
|
|
300
300
|
...G,
|
|
301
|
-
[
|
|
301
|
+
[S]: j(G[S] ?? [])
|
|
302
302
|
}));
|
|
303
303
|
}
|
|
304
|
-
function ie(
|
|
305
|
-
|
|
304
|
+
function ie(S, j) {
|
|
305
|
+
C((G) => ({ ...G, [S]: j }));
|
|
306
306
|
}
|
|
307
|
-
function le(
|
|
308
|
-
f((G) => ({ ...G, [
|
|
307
|
+
function le(S, j) {
|
|
308
|
+
f((G) => ({ ...G, [S]: j }));
|
|
309
309
|
}
|
|
310
|
-
function ge(
|
|
311
|
-
A((G) => ({ ...G, [
|
|
310
|
+
function ge(S, j) {
|
|
311
|
+
A((G) => ({ ...G, [S]: j }));
|
|
312
312
|
}
|
|
313
|
-
function T(
|
|
314
|
-
de.current !== null && window.clearTimeout(de.current), u({ group:
|
|
315
|
-
u((G) => (G == null ? void 0 : G.group) ===
|
|
313
|
+
function T(S, j) {
|
|
314
|
+
de.current !== null && window.clearTimeout(de.current), u({ group: S, item: j, key: Date.now() }), de.current = window.setTimeout(() => {
|
|
315
|
+
u((G) => (G == null ? void 0 : G.group) === S && (G == null ? void 0 : G.item) === j ? null : G), de.current = null;
|
|
316
316
|
}, 1100);
|
|
317
317
|
}
|
|
318
|
-
function Q(
|
|
319
|
-
return [...
|
|
318
|
+
function Q(S) {
|
|
319
|
+
return [...S].sort((j, G) => {
|
|
320
320
|
const we = Ve(V.current[j.id]) || Ve(j.last_message_at || void 0) || Ve(j.created_at);
|
|
321
321
|
return (Ve(V.current[G.id]) || Ve(G.last_message_at || void 0) || Ve(G.created_at)) - we;
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
|
-
function ce(
|
|
325
|
-
s((j) => Q(
|
|
324
|
+
function ce(S) {
|
|
325
|
+
s((j) => Q(S(j)));
|
|
326
326
|
}
|
|
327
|
-
function ae(
|
|
328
|
-
const G = j || (/* @__PURE__ */ new Date()).toISOString(), we = V.current[
|
|
327
|
+
function ae(S, j) {
|
|
328
|
+
const G = j || (/* @__PURE__ */ new Date()).toISOString(), we = V.current[S];
|
|
329
329
|
Ve(G) >= Ve(we) && (V.current = {
|
|
330
330
|
...V.current,
|
|
331
|
-
[
|
|
331
|
+
[S]: G
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
|
-
function Be(
|
|
334
|
+
function Be(S) {
|
|
335
335
|
const j = { ...V.current };
|
|
336
|
-
for (const G of
|
|
336
|
+
for (const G of S)
|
|
337
337
|
G.last_message_at && !j[G.id] && (j[G.id] = G.last_message_at);
|
|
338
338
|
V.current = j;
|
|
339
339
|
}
|
|
340
|
-
function Ae(
|
|
340
|
+
function Ae(S) {
|
|
341
341
|
const j = W.current;
|
|
342
342
|
if (!j || j.readyState !== WebSocket.OPEN)
|
|
343
343
|
throw new Error("Chat is disconnected.");
|
|
344
|
-
j.send(JSON.stringify(
|
|
344
|
+
j.send(JSON.stringify(S));
|
|
345
345
|
}
|
|
346
|
-
function _e(
|
|
346
|
+
function _e(S, j, G) {
|
|
347
347
|
return new Promise((we, fe) => {
|
|
348
348
|
const ve = qa();
|
|
349
349
|
I.current.set(ve, {
|
|
@@ -352,20 +352,20 @@ function za({ children: t }) {
|
|
|
352
352
|
reject: fe
|
|
353
353
|
});
|
|
354
354
|
try {
|
|
355
|
-
Ae({ type:
|
|
355
|
+
Ae({ type: S, request_id: ve, ...j });
|
|
356
356
|
} catch (Ze) {
|
|
357
357
|
I.current.delete(ve), fe(Ze instanceof Error ? Ze : new Error("Chat request failed."));
|
|
358
358
|
}
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
se(() => {
|
|
362
|
-
let
|
|
362
|
+
let S = !1;
|
|
363
363
|
function j() {
|
|
364
|
-
if (
|
|
364
|
+
if (S) return;
|
|
365
365
|
D("connecting");
|
|
366
366
|
const we = `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}/ws/chat`, fe = new WebSocket(we);
|
|
367
367
|
W.current = fe, fe.onopen = () => {
|
|
368
|
-
if (
|
|
368
|
+
if (S) {
|
|
369
369
|
fe.close();
|
|
370
370
|
return;
|
|
371
371
|
}
|
|
@@ -414,7 +414,7 @@ function za({ children: t }) {
|
|
|
414
414
|
dn(L), ce((M) => M.filter((U) => U.id !== L)), i((M) => {
|
|
415
415
|
const U = { ...M };
|
|
416
416
|
return delete U[L], U;
|
|
417
|
-
}),
|
|
417
|
+
}), C((M) => {
|
|
418
418
|
const U = { ...M };
|
|
419
419
|
return delete U[L], U;
|
|
420
420
|
}), f((M) => {
|
|
@@ -429,7 +429,7 @@ function za({ children: t }) {
|
|
|
429
429
|
}), d((M) => {
|
|
430
430
|
const U = { ...M };
|
|
431
431
|
return delete U[L], U;
|
|
432
|
-
}),
|
|
432
|
+
}), m((M) => {
|
|
433
433
|
const U = { ...M };
|
|
434
434
|
return delete U[L], U;
|
|
435
435
|
});
|
|
@@ -449,7 +449,7 @@ function za({ children: t }) {
|
|
|
449
449
|
return { ...y, [L]: [...re, ...P] };
|
|
450
450
|
}
|
|
451
451
|
return { ...y, [L]: B };
|
|
452
|
-
}), l((y) => ({ ...y, [L]: U })), d((y) => ({ ...y, [L]: Te })),
|
|
452
|
+
}), l((y) => ({ ...y, [L]: U })), d((y) => ({ ...y, [L]: Te })), m((y) => ({ ...y, [L]: !1 }));
|
|
453
453
|
const be = typeof F.title == "string" ? F.title : null;
|
|
454
454
|
if (be && ce(
|
|
455
455
|
(y) => y.map((P) => P.id === L ? { ...P, title: be } : P)
|
|
@@ -460,7 +460,7 @@ function za({ children: t }) {
|
|
|
460
460
|
return;
|
|
461
461
|
}
|
|
462
462
|
if (me === "history_cleared" && L) {
|
|
463
|
-
i((B) => ({ ...B, [L]: [] })), l((B) => ({ ...B, [L]: !1 })), d((B) => ({ ...B, [L]: null })),
|
|
463
|
+
i((B) => ({ ...B, [L]: [] })), l((B) => ({ ...B, [L]: !1 })), d((B) => ({ ...B, [L]: null })), m((B) => ({ ...B, [L]: !1 })), ie(L, !1), le(L, "idle"), ge(L, null);
|
|
464
464
|
return;
|
|
465
465
|
}
|
|
466
466
|
if (me === "message_added" && L) {
|
|
@@ -534,8 +534,8 @@ function za({ children: t }) {
|
|
|
534
534
|
return;
|
|
535
535
|
}
|
|
536
536
|
if (me === "tool_call" && L) {
|
|
537
|
-
|
|
538
|
-
...
|
|
537
|
+
ee.current = {
|
|
538
|
+
...ee.current,
|
|
539
539
|
[L]: {
|
|
540
540
|
tool: String(F.tool || ""),
|
|
541
541
|
args: F.args
|
|
@@ -552,7 +552,7 @@ function za({ children: t }) {
|
|
|
552
552
|
return;
|
|
553
553
|
}
|
|
554
554
|
if (me === "tool_result" && L) {
|
|
555
|
-
const B =
|
|
555
|
+
const B = ee.current[L];
|
|
556
556
|
if (B && B.tool === String(F.tool || "") && F.success)
|
|
557
557
|
if (B.tool === "create_custom_analytics_report" || B.tool === "update_custom_analytics_report") {
|
|
558
558
|
const U = typeof F.report_id == "string" ? F.report_id : void 0, Te = typeof ((Ze = B.args) == null ? void 0 : Ze.report_id) == "string" ? B.args.report_id : void 0;
|
|
@@ -561,8 +561,8 @@ function za({ children: t }) {
|
|
|
561
561
|
const U = Oa(B.tool, B.args);
|
|
562
562
|
U && T(U.group, U.item);
|
|
563
563
|
}
|
|
564
|
-
|
|
565
|
-
...
|
|
564
|
+
ee.current = {
|
|
565
|
+
...ee.current,
|
|
566
566
|
[L]: null
|
|
567
567
|
}, K(L, (M) => [
|
|
568
568
|
...M,
|
|
@@ -592,17 +592,17 @@ function za({ children: t }) {
|
|
|
592
592
|
}, fe.onerror = () => {
|
|
593
593
|
fe.close();
|
|
594
594
|
}, fe.onclose = (ve) => {
|
|
595
|
-
if (W.current === fe && (W.current = null), R("Chat disconnected."), D("disconnected"), !
|
|
595
|
+
if (W.current === fe && (W.current = null), R("Chat disconnected."), D("disconnected"), !S) {
|
|
596
596
|
if (ve.code === 4001 || ve.code === 4003) {
|
|
597
597
|
window.location.href = "/login";
|
|
598
598
|
return;
|
|
599
599
|
}
|
|
600
|
-
|
|
600
|
+
v.current = window.setTimeout(j, 3e3);
|
|
601
601
|
}
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
return j(), () => {
|
|
605
|
-
if (
|
|
605
|
+
if (S = !0, v.current !== null && window.clearTimeout(v.current), de.current !== null && window.clearTimeout(de.current), R("Chat disconnected."), W.current) {
|
|
606
606
|
const G = W.current;
|
|
607
607
|
W.current = null, G.close();
|
|
608
608
|
}
|
|
@@ -611,90 +611,90 @@ function za({ children: t }) {
|
|
|
611
611
|
async function Ue() {
|
|
612
612
|
if (z.current)
|
|
613
613
|
return z.current;
|
|
614
|
-
const
|
|
615
|
-
z.current ===
|
|
614
|
+
const S = _e("create_session", {}, "session_created").then((j) => j.session).finally(() => {
|
|
615
|
+
z.current === S && (z.current = null);
|
|
616
616
|
});
|
|
617
|
-
return z.current =
|
|
617
|
+
return z.current = S, S;
|
|
618
618
|
}
|
|
619
|
-
async function Re(
|
|
620
|
-
le(
|
|
619
|
+
async function Re(S) {
|
|
620
|
+
le(S, "running"), ge(S, null);
|
|
621
621
|
try {
|
|
622
|
-
await _e("start_demo", { session_id:
|
|
622
|
+
await _e("start_demo", { session_id: S }, "demo_started");
|
|
623
623
|
} catch (j) {
|
|
624
|
-
throw le(
|
|
624
|
+
throw le(S, "idle"), j;
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
-
function he(
|
|
627
|
+
function he(S, j) {
|
|
628
628
|
try {
|
|
629
|
-
Ae({ type: "demo_typing_done", session_id:
|
|
629
|
+
Ae({ type: "demo_typing_done", session_id: S, seq: j });
|
|
630
630
|
} catch {
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
-
async function xe(
|
|
634
|
-
await _e("delete_session", { session_id:
|
|
633
|
+
async function xe(S) {
|
|
634
|
+
await _e("delete_session", { session_id: S }, "session_deleted");
|
|
635
635
|
}
|
|
636
|
-
async function qe(
|
|
637
|
-
await _e("load_history", { session_id:
|
|
636
|
+
async function qe(S) {
|
|
637
|
+
await _e("load_history", { session_id: S }, "history_loaded");
|
|
638
638
|
}
|
|
639
|
-
async function Fe(
|
|
640
|
-
if (
|
|
641
|
-
const j =
|
|
642
|
-
if (j != null && c[
|
|
643
|
-
|
|
639
|
+
async function Fe(S) {
|
|
640
|
+
if (p[S]) return;
|
|
641
|
+
const j = g[S];
|
|
642
|
+
if (j != null && c[S]) {
|
|
643
|
+
m((G) => ({ ...G, [S]: !0 }));
|
|
644
644
|
try {
|
|
645
645
|
await _e(
|
|
646
646
|
"load_history",
|
|
647
|
-
{ session_id:
|
|
647
|
+
{ session_id: S, before_id: j },
|
|
648
648
|
"history_loaded"
|
|
649
649
|
);
|
|
650
650
|
} catch (G) {
|
|
651
|
-
throw
|
|
651
|
+
throw m((we) => ({ ...we, [S]: !1 })), G;
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
-
async function Pe(
|
|
656
|
-
await _e("clear_history", { session_id:
|
|
655
|
+
async function Pe(S) {
|
|
656
|
+
await _e("clear_history", { session_id: S }, "history_cleared");
|
|
657
657
|
}
|
|
658
|
-
function nt(
|
|
658
|
+
function nt(S, j, G) {
|
|
659
659
|
const we = j.trim(), fe = ((G == null ? void 0 : G.length) ?? 0) > 0;
|
|
660
660
|
if (!we && !fe) return !1;
|
|
661
661
|
try {
|
|
662
|
-
ie(
|
|
662
|
+
ie(S, !0);
|
|
663
663
|
const ve = {
|
|
664
664
|
type: "send_message",
|
|
665
|
-
session_id:
|
|
665
|
+
session_id: S,
|
|
666
666
|
content: we
|
|
667
667
|
};
|
|
668
668
|
return fe && (ve.attachment_ids = G), Ae(ve), !0;
|
|
669
669
|
} catch {
|
|
670
|
-
return ie(
|
|
670
|
+
return ie(S, !1), !1;
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
function Je(
|
|
674
|
-
return
|
|
673
|
+
function Je(S) {
|
|
674
|
+
return S ? o[S] ?? [] : [];
|
|
675
675
|
}
|
|
676
|
-
function at(
|
|
677
|
-
return
|
|
676
|
+
function at(S) {
|
|
677
|
+
return S ? !!x[S] : !1;
|
|
678
678
|
}
|
|
679
|
-
function _t(
|
|
680
|
-
return
|
|
679
|
+
function _t(S) {
|
|
680
|
+
return S ? !!c[S] : !1;
|
|
681
681
|
}
|
|
682
|
-
function Ye(
|
|
683
|
-
return
|
|
682
|
+
function Ye(S) {
|
|
683
|
+
return S ? !!p[S] : !1;
|
|
684
684
|
}
|
|
685
|
-
function ht(
|
|
686
|
-
return
|
|
685
|
+
function ht(S) {
|
|
686
|
+
return S ? b[S] ?? "idle" : "idle";
|
|
687
687
|
}
|
|
688
|
-
function Pt(
|
|
689
|
-
return
|
|
688
|
+
function Pt(S) {
|
|
689
|
+
return S ? _[S] ?? null : null;
|
|
690
690
|
}
|
|
691
691
|
return /* @__PURE__ */ e(
|
|
692
692
|
Vn.Provider,
|
|
693
693
|
{
|
|
694
694
|
value: {
|
|
695
695
|
sessions: a,
|
|
696
|
-
connectionStatus:
|
|
697
|
-
connectionVersion:
|
|
696
|
+
connectionStatus: h,
|
|
697
|
+
connectionVersion: k,
|
|
698
698
|
navigationFlash: q,
|
|
699
699
|
createSession: Ue,
|
|
700
700
|
startDemo: Re,
|
|
@@ -896,16 +896,16 @@ const Jt = {
|
|
|
896
896
|
"Custom Analytics": "bg-indigo-300 text-indigo-950 ring-2 ring-inset ring-indigo-100"
|
|
897
897
|
};
|
|
898
898
|
function $a() {
|
|
899
|
-
const [t, n] = Ht("chats"), a =
|
|
899
|
+
const [t, n] = Ht("chats"), a = mt(), s = Oe(), { t: o } = X(), { sessions: i, createSession: c, deleteSession: l } = tt(), g = async () => {
|
|
900
900
|
try {
|
|
901
|
-
const
|
|
902
|
-
s(`/chat/${
|
|
901
|
+
const p = await c();
|
|
902
|
+
s(`/chat/${p.id}`);
|
|
903
903
|
} catch {
|
|
904
904
|
}
|
|
905
|
-
}, d = async (
|
|
906
|
-
|
|
905
|
+
}, d = async (p, m) => {
|
|
906
|
+
p.preventDefault(), p.stopPropagation();
|
|
907
907
|
try {
|
|
908
|
-
await l(
|
|
908
|
+
await l(m), window.location.pathname === `/chat/${m}` && s("/");
|
|
909
909
|
} catch {
|
|
910
910
|
}
|
|
911
911
|
};
|
|
@@ -927,7 +927,7 @@ function $a() {
|
|
|
927
927
|
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ r(
|
|
928
928
|
"button",
|
|
929
929
|
{
|
|
930
|
-
onClick:
|
|
930
|
+
onClick: g,
|
|
931
931
|
className: "flex w-full items-center gap-2 px-4 py-1.5 pl-10 text-sm text-brand transition-colors hover:bg-brand/5",
|
|
932
932
|
children: [
|
|
933
933
|
/* @__PURE__ */ e(On, { className: "h-3.5 w-3.5" }),
|
|
@@ -935,31 +935,31 @@ function $a() {
|
|
|
935
935
|
]
|
|
936
936
|
}
|
|
937
937
|
) }),
|
|
938
|
-
i.map((
|
|
939
|
-
const
|
|
938
|
+
i.map((p) => {
|
|
939
|
+
const m = a.pathname === `/chat/${p.id}`;
|
|
940
940
|
return /* @__PURE__ */ r("li", { className: "group relative", children: [
|
|
941
941
|
/* @__PURE__ */ e(
|
|
942
942
|
St,
|
|
943
943
|
{
|
|
944
|
-
to: `/chat/${
|
|
944
|
+
to: `/chat/${p.id}`,
|
|
945
945
|
className: De(
|
|
946
946
|
"relative block truncate px-4 py-1.5 pl-10 pr-8 text-sm transition-colors",
|
|
947
|
-
|
|
947
|
+
m ? "bg-surface-subtle font-medium text-fg" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"
|
|
948
948
|
),
|
|
949
|
-
children:
|
|
949
|
+
children: p.title
|
|
950
950
|
}
|
|
951
951
|
),
|
|
952
|
-
|
|
952
|
+
m && /* @__PURE__ */ e(Yt, {}),
|
|
953
953
|
/* @__PURE__ */ e(
|
|
954
954
|
"button",
|
|
955
955
|
{
|
|
956
|
-
onClick: (x) => d(x,
|
|
956
|
+
onClick: (x) => d(x, p.id),
|
|
957
957
|
className: "absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-red-500 group-hover:opacity-100",
|
|
958
958
|
title: o("nav.deleteChat"),
|
|
959
959
|
children: /* @__PURE__ */ e(qn, { className: "h-3.5 w-3.5" })
|
|
960
960
|
}
|
|
961
961
|
)
|
|
962
|
-
] },
|
|
962
|
+
] }, p.id);
|
|
963
963
|
})
|
|
964
964
|
] })
|
|
965
965
|
] });
|
|
@@ -974,25 +974,25 @@ function Yt() {
|
|
|
974
974
|
);
|
|
975
975
|
}
|
|
976
976
|
function Ua() {
|
|
977
|
-
const [t, n, a] = Ht("custom-analytics"), s =
|
|
977
|
+
const [t, n, a] = Ht("custom-analytics"), s = mt(), o = Oe(), i = Qe(), { t: c } = X(), { navigationFlash: l, sessions: g, createSession: d } = tt(), p = (l == null ? void 0 : l.group) === "Custom Analytics", m = Jt["Custom Analytics"], { data: x } = oe({
|
|
978
978
|
queryKey: ["runtime-drafts"],
|
|
979
979
|
queryFn: () => O.listRuntimeDrafts(),
|
|
980
980
|
staleTime: 3e4
|
|
981
|
-
}),
|
|
981
|
+
}), C = (x == null ? void 0 : x.drafts) ?? [];
|
|
982
982
|
se(() => {
|
|
983
983
|
(l == null ? void 0 : l.group) === "Custom Analytics" && (a(), i.invalidateQueries({ queryKey: ["runtime-drafts"] }));
|
|
984
984
|
}, [l == null ? void 0 : l.key, i, a]);
|
|
985
|
-
const
|
|
985
|
+
const b = ue({
|
|
986
986
|
mutationFn: (A) => O.deleteRuntimeDraft(A),
|
|
987
987
|
onSuccess: (A, q) => {
|
|
988
988
|
i.invalidateQueries({ queryKey: ["runtime-drafts"] }), s.search.includes(`report_id=${q}`) && o("/reports/analytics");
|
|
989
989
|
}
|
|
990
990
|
}), f = async (A, q) => {
|
|
991
|
-
A.preventDefault(), A.stopPropagation(),
|
|
991
|
+
A.preventDefault(), A.stopPropagation(), b.mutate(q);
|
|
992
992
|
}, _ = async () => {
|
|
993
993
|
var u;
|
|
994
994
|
const A = "Build me a custom analytics report: <describe what you want — e.g. top 10 customers by revenue for the last quarter, or monthly purchases trend by supplier>";
|
|
995
|
-
let q = ((u =
|
|
995
|
+
let q = ((u = g[0]) == null ? void 0 : u.id) || "";
|
|
996
996
|
if (!q)
|
|
997
997
|
try {
|
|
998
998
|
q = (await d()).id;
|
|
@@ -1010,7 +1010,7 @@ function Ua() {
|
|
|
1010
1010
|
onClick: n,
|
|
1011
1011
|
className: De(
|
|
1012
1012
|
"flex w-full items-center gap-2 px-4 py-2 text-xs font-semibold uppercase tracking-wider text-fg-muted transition-all duration-300 hover:text-fg",
|
|
1013
|
-
|
|
1013
|
+
p && m
|
|
1014
1014
|
),
|
|
1015
1015
|
children: [
|
|
1016
1016
|
/* @__PURE__ */ e(va, { className: "h-4 w-4" }),
|
|
@@ -1031,8 +1031,8 @@ function Ua() {
|
|
|
1031
1031
|
]
|
|
1032
1032
|
}
|
|
1033
1033
|
) }),
|
|
1034
|
-
|
|
1035
|
-
const q = `/reports/analytics?report_id=${A.id}`, u = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${A.id}`),
|
|
1034
|
+
C.map((A) => {
|
|
1035
|
+
const q = `/reports/analytics?report_id=${A.id}`, u = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${A.id}`), h = (l == null ? void 0 : l.group) === "Custom Analytics" && (l == null ? void 0 : l.item) === A.id;
|
|
1036
1036
|
return /* @__PURE__ */ r("li", { className: "group relative", children: [
|
|
1037
1037
|
/* @__PURE__ */ e(
|
|
1038
1038
|
St,
|
|
@@ -1042,7 +1042,7 @@ function Ua() {
|
|
|
1042
1042
|
"relative block truncate px-4 py-1.5 pl-10 pr-8 text-sm transition-all duration-300",
|
|
1043
1043
|
!u && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
|
|
1044
1044
|
u && "bg-surface-subtle font-medium text-fg",
|
|
1045
|
-
|
|
1045
|
+
h && m
|
|
1046
1046
|
),
|
|
1047
1047
|
title: A.title,
|
|
1048
1048
|
children: A.title
|
|
@@ -1064,7 +1064,7 @@ function Ua() {
|
|
|
1064
1064
|
] });
|
|
1065
1065
|
}
|
|
1066
1066
|
function Va({ group: t }) {
|
|
1067
|
-
const [n, a] = Ht(t.label), { t: s } =
|
|
1067
|
+
const [n, a] = Ht(t.label), { t: s } = X(), { navigationFlash: o } = tt(), i = (o == null ? void 0 : o.group) === t.label, c = Jt[t.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
|
|
1068
1068
|
return /* @__PURE__ */ r("div", { children: [
|
|
1069
1069
|
/* @__PURE__ */ r(
|
|
1070
1070
|
"button",
|
|
@@ -1083,14 +1083,14 @@ function Va({ group: t }) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
),
|
|
1085
1085
|
n && /* @__PURE__ */ e("ul", { className: "mb-1", children: t.items.map((l) => {
|
|
1086
|
-
const
|
|
1086
|
+
const g = t.items.some(
|
|
1087
1087
|
(d) => d.path !== l.path && d.path.startsWith(l.path + "/")
|
|
1088
1088
|
);
|
|
1089
1089
|
return /* @__PURE__ */ e("li", { className: "relative", children: /* @__PURE__ */ e(
|
|
1090
1090
|
St,
|
|
1091
1091
|
{
|
|
1092
1092
|
to: l.path,
|
|
1093
|
-
end:
|
|
1093
|
+
end: g,
|
|
1094
1094
|
className: ({ isActive: d }) => De(
|
|
1095
1095
|
"relative block px-4 py-1.5 pl-10 text-sm transition-all duration-300",
|
|
1096
1096
|
!d && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
|
|
@@ -1121,10 +1121,10 @@ function Ga({ isMobileOpen: t = !1, onClose: n }) {
|
|
|
1121
1121
|
staleTime: 6e4
|
|
1122
1122
|
}), o = (l = s == null ? void 0 : s.companies) == null ? void 0 : l[0], i = (o == null ? void 0 : o.company_name) || (o == null ? void 0 : o.name) || Ma().appName, c = Ce(() => Fa().map((d) => ({
|
|
1123
1123
|
...d,
|
|
1124
|
-
items: d.items.filter((
|
|
1125
|
-
if (
|
|
1126
|
-
const
|
|
1127
|
-
return !
|
|
1124
|
+
items: d.items.filter((p) => {
|
|
1125
|
+
if (p.path === "/setup" && (s != null && s.setup_complete)) return !1;
|
|
1126
|
+
const m = ja[p.path];
|
|
1127
|
+
return !m || !a ? !0 : a[m] !== "0";
|
|
1128
1128
|
})
|
|
1129
1129
|
})), [a, s]);
|
|
1130
1130
|
return /* @__PURE__ */ r(
|
|
@@ -1172,7 +1172,7 @@ function Ga({ isMobileOpen: t = !1, onClose: n }) {
|
|
|
1172
1172
|
/* @__PURE__ */ r("nav", { className: "flex-1 overflow-y-auto py-3", children: [
|
|
1173
1173
|
/* @__PURE__ */ e($a, {}),
|
|
1174
1174
|
/* @__PURE__ */ e(Ua, {}),
|
|
1175
|
-
c.map((
|
|
1175
|
+
c.map((g) => /* @__PURE__ */ e(Va, { group: g }, g.label))
|
|
1176
1176
|
] })
|
|
1177
1177
|
]
|
|
1178
1178
|
}
|
|
@@ -1202,11 +1202,11 @@ function Ka() {
|
|
|
1202
1202
|
return /* @__PURE__ */ e(za, { children: /* @__PURE__ */ e(Qa, {}) });
|
|
1203
1203
|
}
|
|
1204
1204
|
function Qa() {
|
|
1205
|
-
const { pathname: t } =
|
|
1205
|
+
const { pathname: t } = mt(), { user: n, logout: a } = it(), { navigationFlash: s } = tt(), { t: o } = X(), i = Wa(t, o), [c, l] = N(!1);
|
|
1206
1206
|
se(() => {
|
|
1207
1207
|
l(!1);
|
|
1208
1208
|
}, [t]);
|
|
1209
|
-
const
|
|
1209
|
+
const g = s ? Jt[s.group] : null;
|
|
1210
1210
|
return /* @__PURE__ */ r("div", { className: "flex h-dvh bg-surface-muted", children: [
|
|
1211
1211
|
/* @__PURE__ */ e(Ga, { isMobileOpen: c, onClose: () => l(!1) }),
|
|
1212
1212
|
c && /* @__PURE__ */ e(
|
|
@@ -1226,7 +1226,7 @@ function Qa() {
|
|
|
1226
1226
|
onClick: () => l(!0),
|
|
1227
1227
|
className: De(
|
|
1228
1228
|
"rounded p-1 text-gray-500 transition-all duration-300 hover:bg-gray-100 hover:text-gray-900 md:hidden",
|
|
1229
|
-
|
|
1229
|
+
g
|
|
1230
1230
|
),
|
|
1231
1231
|
"aria-label": o("header.openMenu"),
|
|
1232
1232
|
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "22", height: "22", children: /* @__PURE__ */ e("path", { d: "M6.835 4c-.451.004-.82.012-1.137.038-.386.032-.659.085-.876.162l-.2.086c-.44.224-.807.564-1.063.982l-.103.184c-.126.247-.206.562-.248 1.076-.043.523-.043 1.19-.043 2.135v2.664c0 .944 0 1.612.043 2.135.042.515.122.829.248 1.076l.103.184c.256.418.624.758 1.063.982l.2.086c.217.077.49.13.876.162.316.026.685.034 1.136.038zm11.33 7.327c0 .922 0 1.654-.048 2.243-.043.522-.125.977-.305 1.395l-.082.177a4 4 0 0 1-1.473 1.593l-.276.155c-.465.237-.974.338-1.57.387-.59.048-1.322.048-2.244.048H7.833c-.922 0-1.654 0-2.243-.048-.522-.042-.977-.126-1.395-.305l-.176-.082a4 4 0 0 1-1.594-1.473l-.154-.275c-.238-.466-.34-.975-.388-1.572-.048-.589-.048-1.32-.048-2.243V8.663c0-.922 0-1.654.048-2.243.049-.597.15-1.106.388-1.571l.154-.276a4 4 0 0 1 1.594-1.472l.176-.083c.418-.18.873-.263 1.395-.305.589-.048 1.32-.048 2.243-.048h4.334c.922 0 1.654 0 2.243.048.597.049 1.106.15 1.571.388l.276.154a4 4 0 0 1 1.473 1.594l.082.176c.18.418.262.873.305 1.395.048.589.048 1.32.048 2.243zm-10 4.668h4.002c.944 0 1.612 0 2.135-.043.514-.042.829-.122 1.076-.248l.184-.103c.418-.256.758-.624.982-1.063l.086-.2c.077-.217.13-.49.162-.876.043-.523.043-1.19.043-2.135V8.663c0-.944 0-1.612-.043-2.135-.032-.386-.085-.659-.162-.876l-.086-.2a2.67 2.67 0 0 0-.982-1.063l-.184-.103c-.247-.126-.562-.206-1.076-.248-.523-.043-1.19-.043-2.135-.043H8.164L8.165 4z" }) })
|
|
@@ -1254,7 +1254,7 @@ function Qa() {
|
|
|
1254
1254
|
] });
|
|
1255
1255
|
}
|
|
1256
1256
|
function Ha({ children: t }) {
|
|
1257
|
-
const { user: n, loading: a } =
|
|
1257
|
+
const { user: n, loading: a } = it();
|
|
1258
1258
|
return a ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-gray-400", children: "Loading..." }) }) : n ? /* @__PURE__ */ e(Ne, { children: t }) : /* @__PURE__ */ e(da, { to: "/login", replace: !0 });
|
|
1259
1259
|
}
|
|
1260
1260
|
function $({ title: t, children: n, className: a, interactive: s }) {
|
|
@@ -1315,7 +1315,7 @@ const Za = {
|
|
|
1315
1315
|
Overdue: "danger"
|
|
1316
1316
|
};
|
|
1317
1317
|
function Zt({ status: t }) {
|
|
1318
|
-
const { t: n } =
|
|
1318
|
+
const { t: n } = X(), a = Za[t] ?? "secondary";
|
|
1319
1319
|
return /* @__PURE__ */ e(Ya, { variant: a, children: n(`status.${t}`, { defaultValue: t }) });
|
|
1320
1320
|
}
|
|
1321
1321
|
function Me(t) {
|
|
@@ -1360,7 +1360,7 @@ const Xa = {
|
|
|
1360
1360
|
Quotation: Gt
|
|
1361
1361
|
};
|
|
1362
1362
|
function er({ doc: t }) {
|
|
1363
|
-
const { t: n } =
|
|
1363
|
+
const { t: n } = X(), a = t.doctype ?? t.type ?? "Document", s = t.creation ?? t.date, o = Xa[a] ?? Gt, c = `/app/${a.toLowerCase().replace(/\s+/g, "-")}/${encodeURIComponent(t.name)}`;
|
|
1364
1364
|
return /* @__PURE__ */ r(
|
|
1365
1365
|
ye,
|
|
1366
1366
|
{
|
|
@@ -1378,7 +1378,7 @@ function er({ doc: t }) {
|
|
|
1378
1378
|
}
|
|
1379
1379
|
);
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1381
|
+
function ct() {
|
|
1382
1382
|
return /* @__PURE__ */ r("div", { className: "grid grid-cols-[auto_1fr_auto_auto] items-center gap-3 px-3 py-2.5", children: [
|
|
1383
1383
|
/* @__PURE__ */ e("div", { className: "h-7 w-7 animate-pulse rounded-md bg-surface-subtle" }),
|
|
1384
1384
|
/* @__PURE__ */ r("div", { className: "min-w-0 space-y-1.5", children: [
|
|
@@ -1390,7 +1390,7 @@ function lt() {
|
|
|
1390
1390
|
] });
|
|
1391
1391
|
}
|
|
1392
1392
|
function tr() {
|
|
1393
|
-
const { t } =
|
|
1393
|
+
const { t } = X(), { data: n, isLoading: a } = oe({
|
|
1394
1394
|
queryKey: ["dashboard-summary"],
|
|
1395
1395
|
queryFn: () => O.dashboardSummary()
|
|
1396
1396
|
});
|
|
@@ -1439,11 +1439,11 @@ function tr() {
|
|
|
1439
1439
|
)
|
|
1440
1440
|
] }) }),
|
|
1441
1441
|
/* @__PURE__ */ e($, { title: t("dashboard.recentDocuments"), children: /* @__PURE__ */ e("div", { className: "-mx-3 space-y-0.5", children: a ? /* @__PURE__ */ r(Ne, { children: [
|
|
1442
|
-
/* @__PURE__ */ e(
|
|
1443
|
-
/* @__PURE__ */ e(
|
|
1444
|
-
/* @__PURE__ */ e(
|
|
1445
|
-
/* @__PURE__ */ e(
|
|
1446
|
-
/* @__PURE__ */ e(
|
|
1442
|
+
/* @__PURE__ */ e(ct, {}),
|
|
1443
|
+
/* @__PURE__ */ e(ct, {}),
|
|
1444
|
+
/* @__PURE__ */ e(ct, {}),
|
|
1445
|
+
/* @__PURE__ */ e(ct, {}),
|
|
1446
|
+
/* @__PURE__ */ e(ct, {})
|
|
1447
1447
|
] }) : n != null && n.recent_documents && n.recent_documents.length > 0 ? n.recent_documents.map((s, o) => /* @__PURE__ */ e(er, { doc: s }, `${s.name}-${o}`)) : /* @__PURE__ */ e("div", { className: "px-3 py-10 text-center text-sm text-fg-muted", children: t("dashboard.noRecentDocuments") }) }) })
|
|
1448
1448
|
] });
|
|
1449
1449
|
}
|
|
@@ -1485,8 +1485,8 @@ function J(t, n) {
|
|
|
1485
1485
|
const c = ke(
|
|
1486
1486
|
(l) => {
|
|
1487
1487
|
s(
|
|
1488
|
-
(
|
|
1489
|
-
const d = new URLSearchParams(
|
|
1488
|
+
(g) => {
|
|
1489
|
+
const d = new URLSearchParams(g);
|
|
1490
1490
|
return l === n || l === "" || l == null ? d.delete(t) : d.set(t, String(l)), d;
|
|
1491
1491
|
},
|
|
1492
1492
|
{ replace: !0 }
|
|
@@ -2133,7 +2133,7 @@ const ar = {
|
|
|
2133
2133
|
md: "h-10 px-4 text-sm",
|
|
2134
2134
|
lg: "h-11 px-5 text-sm"
|
|
2135
2135
|
};
|
|
2136
|
-
function
|
|
2136
|
+
function Z({
|
|
2137
2137
|
variant: t = "primary",
|
|
2138
2138
|
size: n = "md",
|
|
2139
2139
|
disabled: a,
|
|
@@ -2243,9 +2243,9 @@ function He({ label: t, options: n, value: a, onChange: s, className: o, require
|
|
|
2243
2243
|
),
|
|
2244
2244
|
children: [
|
|
2245
2245
|
/* @__PURE__ */ e("option", { value: "", children: "Select..." }),
|
|
2246
|
-
n.map((
|
|
2247
|
-
const { value: d, label:
|
|
2248
|
-
return /* @__PURE__ */ e("option", { value: d, children:
|
|
2246
|
+
n.map((g) => {
|
|
2247
|
+
const { value: d, label: p } = sr(g);
|
|
2248
|
+
return /* @__PURE__ */ e("option", { value: d, children: p }, d);
|
|
2249
2249
|
})
|
|
2250
2250
|
]
|
|
2251
2251
|
}
|
|
@@ -2303,7 +2303,7 @@ function dr({
|
|
|
2303
2303
|
disabled: s,
|
|
2304
2304
|
hideLabel: o
|
|
2305
2305
|
}) {
|
|
2306
|
-
const [i, c] = N(n ?? ""), [l,
|
|
2306
|
+
const [i, c] = N(n ?? ""), [l, g] = N(!1), { data: d } = oe({
|
|
2307
2307
|
queryKey: ["link-search", t.linkDoctype, i],
|
|
2308
2308
|
queryFn: () => O.searchLink(t.linkDoctype, i),
|
|
2309
2309
|
enabled: !!t.linkDoctype && l
|
|
@@ -2319,23 +2319,23 @@ function dr({
|
|
|
2319
2319
|
{
|
|
2320
2320
|
label: o ? void 0 : t.label,
|
|
2321
2321
|
value: i,
|
|
2322
|
-
onChange: (
|
|
2323
|
-
c(
|
|
2322
|
+
onChange: (p) => {
|
|
2323
|
+
c(p.target.value), g(!0);
|
|
2324
2324
|
},
|
|
2325
|
-
onFocus: () =>
|
|
2326
|
-
onBlur: () => setTimeout(() =>
|
|
2325
|
+
onFocus: () => g(!0),
|
|
2326
|
+
onBlur: () => setTimeout(() => g(!1), 200)
|
|
2327
2327
|
}
|
|
2328
2328
|
),
|
|
2329
|
-
l && d && d.length > 0 && /* @__PURE__ */ e("ul", { className: "absolute z-10 mt-1 max-h-40 w-full overflow-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: d.map((
|
|
2329
|
+
l && d && d.length > 0 && /* @__PURE__ */ e("ul", { className: "absolute z-10 mt-1 max-h-40 w-full overflow-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: d.map((p) => /* @__PURE__ */ e(
|
|
2330
2330
|
"li",
|
|
2331
2331
|
{
|
|
2332
2332
|
className: "cursor-pointer px-3 py-2 text-sm text-fg transition-colors hover:bg-surface-subtle",
|
|
2333
2333
|
onMouseDown: () => {
|
|
2334
|
-
a(
|
|
2334
|
+
a(p.name), c(p.name), g(!1);
|
|
2335
2335
|
},
|
|
2336
|
-
children:
|
|
2336
|
+
children: p.name
|
|
2337
2337
|
},
|
|
2338
|
-
|
|
2338
|
+
p.name
|
|
2339
2339
|
)) })
|
|
2340
2340
|
] });
|
|
2341
2341
|
}
|
|
@@ -2348,9 +2348,9 @@ function Ut({
|
|
|
2348
2348
|
hideLabel: i,
|
|
2349
2349
|
currency: c = "USD"
|
|
2350
2350
|
}) {
|
|
2351
|
-
var
|
|
2352
|
-
const { t: l } =
|
|
2353
|
-
if (
|
|
2351
|
+
var C;
|
|
2352
|
+
const { t: l } = X(), g = s || !!t.readOnly, d = () => i ? null : /* @__PURE__ */ e(cr, { label: l(`fields.${t.label}`, { defaultValue: t.label }), hint: t.hint }), p = t.type === "select" && t.optionsSource === "currency", m = or(void 0, p);
|
|
2353
|
+
if (g) {
|
|
2354
2354
|
if (t.type === "link" && n) {
|
|
2355
2355
|
const f = t.linkDoctypeField && o ? String(o[t.linkDoctypeField] ?? "").toLowerCase().replace(/\s+/g, "-") : t.linkDoctype, _ = $t(f, String(n));
|
|
2356
2356
|
if (_)
|
|
@@ -2366,36 +2366,36 @@ function Ut({
|
|
|
2366
2366
|
) })
|
|
2367
2367
|
] });
|
|
2368
2368
|
}
|
|
2369
|
-
let
|
|
2370
|
-
return t.type === "currency" && typeof n == "number" && (
|
|
2369
|
+
let b = n ?? "-";
|
|
2370
|
+
return t.type === "currency" && typeof n == "number" && (b = Le(n, c)), /* @__PURE__ */ r("div", { children: [
|
|
2371
2371
|
/* @__PURE__ */ e(d, {}),
|
|
2372
|
-
/* @__PURE__ */ e("p", { className: i ? "text-sm text-fg" : "py-2 text-sm text-fg", children:
|
|
2372
|
+
/* @__PURE__ */ e("p", { className: i ? "text-sm text-fg" : "py-2 text-sm text-fg", children: b })
|
|
2373
2373
|
] });
|
|
2374
2374
|
}
|
|
2375
2375
|
if (t.type === "link") {
|
|
2376
|
-
const
|
|
2376
|
+
const b = t.linkDoctypeField && o ? { ...t, linkDoctype: (C = o[t.linkDoctypeField]) == null ? void 0 : C.toLowerCase().replace(/\s+/g, "-") } : t;
|
|
2377
2377
|
return /* @__PURE__ */ r("div", { children: [
|
|
2378
2378
|
/* @__PURE__ */ e(d, {}),
|
|
2379
2379
|
/* @__PURE__ */ e(
|
|
2380
2380
|
dr,
|
|
2381
2381
|
{
|
|
2382
|
-
field:
|
|
2382
|
+
field: b,
|
|
2383
2383
|
value: n ?? "",
|
|
2384
2384
|
onChange: a,
|
|
2385
|
-
disabled:
|
|
2385
|
+
disabled: g,
|
|
2386
2386
|
hideLabel: !0
|
|
2387
2387
|
}
|
|
2388
2388
|
)
|
|
2389
2389
|
] });
|
|
2390
2390
|
}
|
|
2391
|
-
if (t.type === "select" && (t.options ||
|
|
2392
|
-
const
|
|
2391
|
+
if (t.type === "select" && (t.options || p)) {
|
|
2392
|
+
const b = p ? n && !m.includes(n) ? [n, ...m] : m : t.options;
|
|
2393
2393
|
return /* @__PURE__ */ r("div", { children: [
|
|
2394
2394
|
/* @__PURE__ */ e(d, {}),
|
|
2395
2395
|
/* @__PURE__ */ e(
|
|
2396
2396
|
He,
|
|
2397
2397
|
{
|
|
2398
|
-
options:
|
|
2398
|
+
options: b,
|
|
2399
2399
|
value: n ?? "",
|
|
2400
2400
|
onChange: (f) => a(f.target.value)
|
|
2401
2401
|
}
|
|
@@ -2411,7 +2411,7 @@ function Ut({
|
|
|
2411
2411
|
className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30",
|
|
2412
2412
|
rows: 3,
|
|
2413
2413
|
value: n ?? "",
|
|
2414
|
-
onChange: (
|
|
2414
|
+
onChange: (b) => a(b.target.value)
|
|
2415
2415
|
}
|
|
2416
2416
|
)
|
|
2417
2417
|
] });
|
|
@@ -2424,8 +2424,8 @@ function Ut({
|
|
|
2424
2424
|
type: x,
|
|
2425
2425
|
step: t.type === "currency" ? "0.01" : void 0,
|
|
2426
2426
|
value: n ?? "",
|
|
2427
|
-
onChange: (
|
|
2428
|
-
x === "number" ? parseFloat(
|
|
2427
|
+
onChange: (b) => a(
|
|
2428
|
+
x === "number" ? parseFloat(b.target.value) || 0 : b.target.value
|
|
2429
2429
|
)
|
|
2430
2430
|
}
|
|
2431
2431
|
)
|
|
@@ -2438,18 +2438,18 @@ function ur({
|
|
|
2438
2438
|
readOnly: s,
|
|
2439
2439
|
currency: o = "USD"
|
|
2440
2440
|
}) {
|
|
2441
|
-
const { t: i } =
|
|
2441
|
+
const { t: i } = X(), c = (d, p, m) => {
|
|
2442
2442
|
const x = n.map(
|
|
2443
|
-
(
|
|
2443
|
+
(C, b) => b === d ? { ...C, [p]: m } : C
|
|
2444
2444
|
);
|
|
2445
2445
|
a(x);
|
|
2446
2446
|
}, l = () => {
|
|
2447
2447
|
const d = {};
|
|
2448
|
-
t.fields.forEach((
|
|
2449
|
-
d[
|
|
2448
|
+
t.fields.forEach((p) => {
|
|
2449
|
+
d[p.name] = p.default ?? (p.type === "number" || p.type === "currency" ? 0 : "");
|
|
2450
2450
|
}), a([...n, d]);
|
|
2451
|
-
},
|
|
2452
|
-
a(n.filter((
|
|
2451
|
+
}, g = (d) => {
|
|
2452
|
+
a(n.filter((p, m) => m !== d));
|
|
2453
2453
|
};
|
|
2454
2454
|
return /* @__PURE__ */ r($, { title: i(`tables.${t.key}`, { defaultValue: t.label }), children: [
|
|
2455
2455
|
/* @__PURE__ */ e("div", { className: "-mx-6 overflow-x-auto px-6", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
|
|
@@ -2465,32 +2465,32 @@ function ur({
|
|
|
2465
2465
|
)),
|
|
2466
2466
|
!s && /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left text-xs font-medium uppercase tracking-wide text-fg-muted" })
|
|
2467
2467
|
] }) }),
|
|
2468
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: n.map((d,
|
|
2469
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1 text-fg-muted", children:
|
|
2470
|
-
t.fields.map((
|
|
2468
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: n.map((d, p) => /* @__PURE__ */ r("tr", { children: [
|
|
2469
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1 text-fg-muted", children: p + 1 }),
|
|
2470
|
+
t.fields.map((m) => /* @__PURE__ */ e("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ e(
|
|
2471
2471
|
Ut,
|
|
2472
2472
|
{
|
|
2473
|
-
field:
|
|
2474
|
-
value: d[
|
|
2475
|
-
onChange: (x) => c(
|
|
2473
|
+
field: m,
|
|
2474
|
+
value: d[m.name],
|
|
2475
|
+
onChange: (x) => c(p, m.name, x),
|
|
2476
2476
|
readOnly: s,
|
|
2477
2477
|
rowData: d,
|
|
2478
2478
|
hideLabel: !0,
|
|
2479
2479
|
currency: o
|
|
2480
2480
|
}
|
|
2481
|
-
) },
|
|
2481
|
+
) }, m.name)),
|
|
2482
2482
|
!s && /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(
|
|
2483
|
-
|
|
2483
|
+
Z,
|
|
2484
2484
|
{
|
|
2485
2485
|
variant: "ghost",
|
|
2486
2486
|
size: "sm",
|
|
2487
|
-
onClick: () =>
|
|
2487
|
+
onClick: () => g(p),
|
|
2488
2488
|
children: "Remove"
|
|
2489
2489
|
}
|
|
2490
2490
|
) })
|
|
2491
|
-
] },
|
|
2491
|
+
] }, p)) })
|
|
2492
2492
|
] }) }),
|
|
2493
|
-
!s && /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e(
|
|
2493
|
+
!s && /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e(Z, { variant: "secondary", size: "sm", onClick: l, children: i("common.addRow") }) })
|
|
2494
2494
|
] });
|
|
2495
2495
|
}
|
|
2496
2496
|
function mr({
|
|
@@ -2502,23 +2502,23 @@ function mr({
|
|
|
2502
2502
|
config: i,
|
|
2503
2503
|
onSave: c,
|
|
2504
2504
|
onSubmit: l,
|
|
2505
|
-
onCancel:
|
|
2505
|
+
onCancel: g,
|
|
2506
2506
|
onConvert: d
|
|
2507
2507
|
}) {
|
|
2508
|
-
const { t:
|
|
2508
|
+
const { t: p } = X();
|
|
2509
2509
|
if (!i) return null;
|
|
2510
|
-
const
|
|
2510
|
+
const m = !t && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null;
|
|
2511
2511
|
return /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-2", children: [
|
|
2512
|
-
|
|
2513
|
-
s < 1 && /* @__PURE__ */ e(
|
|
2514
|
-
!t && i.canSubmit && s === 0 && /* @__PURE__ */ e(
|
|
2515
|
-
!t && i.canCancel && s === 1 && /* @__PURE__ */ e(
|
|
2512
|
+
m && /* @__PURE__ */ e(Z, { variant: "secondary", onClick: () => window.open(m, "_blank"), children: p("common.pdf") }),
|
|
2513
|
+
s < 1 && /* @__PURE__ */ e(Z, { onClick: c, disabled: o, children: p(o ? "common.saving" : "common.save") }),
|
|
2514
|
+
!t && i.canSubmit && s === 0 && /* @__PURE__ */ e(Z, { variant: "secondary", onClick: l, children: p("common.submit") }),
|
|
2515
|
+
!t && i.canCancel && s === 1 && /* @__PURE__ */ e(Z, { variant: "danger", onClick: g, children: p("common.cancelDoc") }),
|
|
2516
2516
|
!t && s === 1 && i.conversions.map((x) => /* @__PURE__ */ e(
|
|
2517
|
-
|
|
2517
|
+
Z,
|
|
2518
2518
|
{
|
|
2519
2519
|
variant: "secondary",
|
|
2520
2520
|
onClick: () => d(x.targetDoctype),
|
|
2521
|
-
children:
|
|
2521
|
+
children: p(`conversions.${x.label}`, { defaultValue: x.label })
|
|
2522
2522
|
},
|
|
2523
2523
|
x.targetDoctype
|
|
2524
2524
|
))
|
|
@@ -2548,31 +2548,31 @@ function pn(t, n) {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
function hn() {
|
|
2550
2550
|
var ge;
|
|
2551
|
-
const { doctype: t, name: n } =
|
|
2551
|
+
const { doctype: t, name: n } = pt(), a = Oe(), s = Qe(), { t: o } = X(), i = Qn(t ?? ""), c = !n, [l, g] = N({}), [d, p] = N(!1), { data: m, isLoading: x } = oe({
|
|
2552
2552
|
queryKey: ["document", t, n],
|
|
2553
2553
|
queryFn: () => O.getDocument(t, n),
|
|
2554
2554
|
enabled: !!t && !!n && !c
|
|
2555
|
-
}),
|
|
2555
|
+
}), C = Ce(
|
|
2556
2556
|
() => !!(i != null && i.fields.some((T) => T.name === "currency")),
|
|
2557
2557
|
[i]
|
|
2558
|
-
),
|
|
2559
|
-
queryKey: ["master",
|
|
2560
|
-
queryFn: () => O.getMaster(
|
|
2561
|
-
enabled: c &&
|
|
2558
|
+
), b = i == null ? void 0 : i.partyField, f = b ? l[b] : void 0, _ = Me(l.company), { data: A } = oe({
|
|
2559
|
+
queryKey: ["master", b, f],
|
|
2560
|
+
queryFn: () => O.getMaster(b, f),
|
|
2561
|
+
enabled: c && C && !!b && !!f,
|
|
2562
2562
|
staleTime: 300 * 1e3
|
|
2563
2563
|
});
|
|
2564
2564
|
se(() => {
|
|
2565
|
-
if (!c || !
|
|
2565
|
+
if (!c || !C || d) return;
|
|
2566
2566
|
let T;
|
|
2567
2567
|
if (f) {
|
|
2568
2568
|
if (!A) return;
|
|
2569
2569
|
T = A.default_currency || _;
|
|
2570
2570
|
} else
|
|
2571
2571
|
T = _;
|
|
2572
|
-
T && T !== l.currency &&
|
|
2572
|
+
T && T !== l.currency && g((Q) => ({ ...Q, currency: T }));
|
|
2573
2573
|
}, [
|
|
2574
2574
|
c,
|
|
2575
|
-
|
|
2575
|
+
C,
|
|
2576
2576
|
d,
|
|
2577
2577
|
f,
|
|
2578
2578
|
A,
|
|
@@ -2585,9 +2585,9 @@ function hn() {
|
|
|
2585
2585
|
Q.type === "date" ? T[Q.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : T[Q.name] = Q.default ?? "";
|
|
2586
2586
|
}), i.childTables.forEach((Q) => {
|
|
2587
2587
|
T[Q.key] = [];
|
|
2588
|
-
}), T.docstatus = 0,
|
|
2589
|
-
} else
|
|
2590
|
-
}, [c,
|
|
2588
|
+
}), T.docstatus = 0, g(T);
|
|
2589
|
+
} else m && g(m);
|
|
2590
|
+
}, [c, m, i]);
|
|
2591
2591
|
const q = ue({
|
|
2592
2592
|
mutationFn: (T) => O.createDocument(t, T),
|
|
2593
2593
|
onSuccess: (T) => {
|
|
@@ -2596,19 +2596,19 @@ function hn() {
|
|
|
2596
2596
|
}), u = ue({
|
|
2597
2597
|
mutationFn: (T) => O.updateDocument(t, n, T),
|
|
2598
2598
|
onSuccess: (T) => {
|
|
2599
|
-
s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] }),
|
|
2599
|
+
s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] }), g(T);
|
|
2600
2600
|
}
|
|
2601
|
-
}),
|
|
2601
|
+
}), h = ue({
|
|
2602
2602
|
mutationFn: () => O.submitDocument(t, n),
|
|
2603
2603
|
onSuccess: (T) => {
|
|
2604
|
-
|
|
2604
|
+
g(T), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
|
|
2605
2605
|
}
|
|
2606
2606
|
}), D = ue({
|
|
2607
2607
|
mutationFn: () => O.cancelDocument(t, n),
|
|
2608
2608
|
onSuccess: (T) => {
|
|
2609
|
-
|
|
2609
|
+
g(T), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
|
|
2610
2610
|
}
|
|
2611
|
-
}),
|
|
2611
|
+
}), k = ue({
|
|
2612
2612
|
mutationFn: (T) => O.convertDocument(t, n, T),
|
|
2613
2613
|
onSuccess: (T, Q) => {
|
|
2614
2614
|
const ce = Q.toLowerCase().replace(/\s+/g, "-");
|
|
@@ -2616,7 +2616,7 @@ function hn() {
|
|
|
2616
2616
|
}
|
|
2617
2617
|
}), w = ke(
|
|
2618
2618
|
(T, Q) => {
|
|
2619
|
-
T === "currency" &&
|
|
2619
|
+
T === "currency" && p(!0), g((ce) => {
|
|
2620
2620
|
const ae = { ...ce, [T]: Q };
|
|
2621
2621
|
return T === "currency" && (ae.conversion_rate = 0), pn(ae, i);
|
|
2622
2622
|
});
|
|
@@ -2624,20 +2624,20 @@ function hn() {
|
|
|
2624
2624
|
[i]
|
|
2625
2625
|
), W = ke(
|
|
2626
2626
|
(T, Q) => {
|
|
2627
|
-
|
|
2627
|
+
g((ce) => {
|
|
2628
2628
|
const ae = { ...ce, [T]: Q };
|
|
2629
2629
|
return pn(ae, i);
|
|
2630
2630
|
});
|
|
2631
2631
|
},
|
|
2632
2632
|
[i]
|
|
2633
|
-
),
|
|
2633
|
+
), v = () => {
|
|
2634
2634
|
c ? q.mutate(l) : u.mutate(l);
|
|
2635
2635
|
}, I = () => {
|
|
2636
|
-
|
|
2636
|
+
h.mutate();
|
|
2637
2637
|
}, z = () => {
|
|
2638
2638
|
D.mutate();
|
|
2639
2639
|
}, V = (T) => {
|
|
2640
|
-
|
|
2640
|
+
k.mutate(T);
|
|
2641
2641
|
};
|
|
2642
2642
|
if (!i)
|
|
2643
2643
|
return /* @__PURE__ */ r("p", { className: "text-fg-muted", children: [
|
|
@@ -2646,7 +2646,7 @@ function hn() {
|
|
|
2646
2646
|
] });
|
|
2647
2647
|
if (!c && x)
|
|
2648
2648
|
return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: o("common.loading") });
|
|
2649
|
-
const
|
|
2649
|
+
const ee = l.docstatus ?? 0, de = ee >= 1, R = l.currency || "USD", K = Ee(l.conversion_rate ?? 1), ie = i.fields.filter((T) => !T.readOnly), le = i.fields.filter((T) => T.readOnly);
|
|
2650
2650
|
return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
2651
2651
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
|
|
2652
2652
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
@@ -2672,17 +2672,17 @@ function hn() {
|
|
|
2672
2672
|
isNew: c,
|
|
2673
2673
|
doctype: t,
|
|
2674
2674
|
name: n,
|
|
2675
|
-
docstatus:
|
|
2675
|
+
docstatus: ee,
|
|
2676
2676
|
saving: q.isPending || u.isPending,
|
|
2677
2677
|
config: i,
|
|
2678
|
-
onSave:
|
|
2678
|
+
onSave: v,
|
|
2679
2679
|
onSubmit: I,
|
|
2680
2680
|
onCancel: z,
|
|
2681
2681
|
onConvert: V
|
|
2682
2682
|
}
|
|
2683
2683
|
)
|
|
2684
2684
|
] }),
|
|
2685
|
-
(q.error || u.error ||
|
|
2685
|
+
(q.error || u.error || h.error || D.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((ge = q.error ?? u.error ?? h.error ?? D.error) == null ? void 0 : ge.message) ?? o("common.errorOccurred") }),
|
|
2686
2686
|
/* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: ie.map((T) => /* @__PURE__ */ e(
|
|
2687
2687
|
Ut,
|
|
2688
2688
|
{
|
|
@@ -2865,18 +2865,18 @@ function br(t) {
|
|
|
2865
2865
|
}
|
|
2866
2866
|
const xr = ["25", "50", "100", "200"];
|
|
2867
2867
|
function vr() {
|
|
2868
|
-
const { t } =
|
|
2869
|
-
const
|
|
2870
|
-
return s !== "All" && (
|
|
2871
|
-
}, [s, o, i, c,
|
|
2868
|
+
const { t } = X(), { doctype: n } = pt(), a = Qn(n ?? ""), [s] = J("status", "All"), [o] = J("from", ""), [i] = J("to", ""), [c] = J("per_page", 50), [l] = J("page", 1), g = l - 1, d = $e(), p = (v) => d({ page: v === 0 ? null : v + 1 }), m = (v) => d({ status: v === "All" ? null : v, page: null }), x = (v) => d({ from: v || null, page: null }), C = (v) => d({ to: v || null, page: null }), b = (v) => d({ per_page: v, page: null }), f = Ce(() => {
|
|
2869
|
+
const v = {};
|
|
2870
|
+
return s !== "All" && (v.status = s), o && (v.from_date = o), i && (v.to_date = i), v.limit = c, v.offset = g * c, v;
|
|
2871
|
+
}, [s, o, i, c, g]), { data: _, isLoading: A } = nr(n ?? "", f), q = (_ == null ? void 0 : _.rows) ?? [], u = (_ == null ? void 0 : _.total) ?? 0, h = Math.max(1, Math.ceil(u / c)), D = u === 0 ? 0 : g * c + 1, k = Math.min(u, (g + 1) * c), w = Ce(() => {
|
|
2872
2872
|
if (!a) return [];
|
|
2873
|
-
const
|
|
2874
|
-
const V = z.split("_").map((
|
|
2873
|
+
const v = zn(), I = (z) => {
|
|
2874
|
+
const V = z.split("_").map((ee) => ee.charAt(0).toUpperCase() + ee.slice(1)).join(" ");
|
|
2875
2875
|
return t(`fields.${V}`, { defaultValue: V });
|
|
2876
2876
|
};
|
|
2877
2877
|
return a.listColumns.map((z) => {
|
|
2878
2878
|
if (z === "name")
|
|
2879
|
-
return
|
|
2879
|
+
return v.accessor("name", {
|
|
2880
2880
|
header: t("fields.Name", { defaultValue: "Name" }),
|
|
2881
2881
|
cell: (V) => /* @__PURE__ */ e(
|
|
2882
2882
|
ye,
|
|
@@ -2888,42 +2888,42 @@ function vr() {
|
|
|
2888
2888
|
)
|
|
2889
2889
|
});
|
|
2890
2890
|
if (z === "status")
|
|
2891
|
-
return
|
|
2891
|
+
return v.accessor("status", {
|
|
2892
2892
|
header: t("fields.Status", { defaultValue: "Status" }),
|
|
2893
2893
|
cell: (V) => /* @__PURE__ */ e(Zt, { status: V.getValue() })
|
|
2894
2894
|
});
|
|
2895
2895
|
if (yr.has(z))
|
|
2896
|
-
return
|
|
2896
|
+
return v.accessor(z, {
|
|
2897
2897
|
header: I(z),
|
|
2898
2898
|
cell: (V) => {
|
|
2899
|
-
var
|
|
2900
|
-
return Le(V.getValue(), ((
|
|
2899
|
+
var ee;
|
|
2900
|
+
return Le(V.getValue(), ((ee = V.row.original) == null ? void 0 : ee.currency) || "USD");
|
|
2901
2901
|
}
|
|
2902
2902
|
});
|
|
2903
2903
|
if (z === "party")
|
|
2904
|
-
return
|
|
2904
|
+
return v.accessor("party", {
|
|
2905
2905
|
header: t("fields.Party", { defaultValue: "Party" }),
|
|
2906
2906
|
cell: (V) => {
|
|
2907
|
-
const
|
|
2908
|
-
if (!
|
|
2909
|
-
const de = br(V.row.original.party_type), R = de ? $t(de, String(
|
|
2907
|
+
const ee = V.getValue();
|
|
2908
|
+
if (!ee) return "-";
|
|
2909
|
+
const de = br(V.row.original.party_type), R = de ? $t(de, String(ee)) : null;
|
|
2910
2910
|
return R ? /* @__PURE__ */ e(
|
|
2911
2911
|
ye,
|
|
2912
2912
|
{
|
|
2913
2913
|
to: R,
|
|
2914
2914
|
onClick: (K) => K.stopPropagation(),
|
|
2915
2915
|
className: "text-brand transition-colors hover:text-brand/80 hover:underline",
|
|
2916
|
-
children:
|
|
2916
|
+
children: ee
|
|
2917
2917
|
}
|
|
2918
|
-
) : String(
|
|
2918
|
+
) : String(ee);
|
|
2919
2919
|
}
|
|
2920
2920
|
});
|
|
2921
2921
|
if (fn[z]) {
|
|
2922
2922
|
const V = fn[z];
|
|
2923
|
-
return
|
|
2923
|
+
return v.accessor(z, {
|
|
2924
2924
|
header: I(z),
|
|
2925
|
-
cell: (
|
|
2926
|
-
const de =
|
|
2925
|
+
cell: (ee) => {
|
|
2926
|
+
const de = ee.getValue();
|
|
2927
2927
|
if (!de) return "-";
|
|
2928
2928
|
const R = $t(V, String(de));
|
|
2929
2929
|
return R ? /* @__PURE__ */ e(
|
|
@@ -2938,10 +2938,10 @@ function vr() {
|
|
|
2938
2938
|
}
|
|
2939
2939
|
});
|
|
2940
2940
|
}
|
|
2941
|
-
return fr.has(z) ?
|
|
2941
|
+
return fr.has(z) ? v.accessor(z, {
|
|
2942
2942
|
header: I(z),
|
|
2943
2943
|
cell: (V) => Ct(V.getValue())
|
|
2944
|
-
}) :
|
|
2944
|
+
}) : v.accessor(z, {
|
|
2945
2945
|
header: I(z)
|
|
2946
2946
|
});
|
|
2947
2947
|
});
|
|
@@ -2951,18 +2951,18 @@ function vr() {
|
|
|
2951
2951
|
getCoreRowModel: Mn()
|
|
2952
2952
|
});
|
|
2953
2953
|
return a ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
2954
|
-
/* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ e(ye, { to: `/app/${a.slug}/new`, children: /* @__PURE__ */ e(
|
|
2954
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ e(ye, { to: `/app/${a.slug}/new`, children: /* @__PURE__ */ e(Z, { children: t("common.new") }) }) }),
|
|
2955
2955
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
2956
2956
|
/* @__PURE__ */ e(
|
|
2957
2957
|
He,
|
|
2958
2958
|
{
|
|
2959
2959
|
label: t("fields.Status", { defaultValue: "Status" }),
|
|
2960
|
-
options: gr.map((
|
|
2961
|
-
value:
|
|
2962
|
-
label:
|
|
2960
|
+
options: gr.map((v) => ({
|
|
2961
|
+
value: v,
|
|
2962
|
+
label: v === "All" ? t("common.all") : t(`status.${v}`, { defaultValue: v })
|
|
2963
2963
|
})),
|
|
2964
2964
|
value: s,
|
|
2965
|
-
onChange: (
|
|
2965
|
+
onChange: (v) => m(v.target.value)
|
|
2966
2966
|
}
|
|
2967
2967
|
),
|
|
2968
2968
|
/* @__PURE__ */ e(
|
|
@@ -2971,7 +2971,7 @@ function vr() {
|
|
|
2971
2971
|
label: t("fields.From Date", { defaultValue: "From Date" }),
|
|
2972
2972
|
type: "date",
|
|
2973
2973
|
value: o,
|
|
2974
|
-
onChange: (
|
|
2974
|
+
onChange: (v) => x(v.target.value)
|
|
2975
2975
|
}
|
|
2976
2976
|
),
|
|
2977
2977
|
/* @__PURE__ */ e(
|
|
@@ -2980,14 +2980,14 @@ function vr() {
|
|
|
2980
2980
|
label: t("fields.To Date", { defaultValue: "To Date" }),
|
|
2981
2981
|
type: "date",
|
|
2982
2982
|
value: i,
|
|
2983
|
-
onChange: (
|
|
2983
|
+
onChange: (v) => C(v.target.value)
|
|
2984
2984
|
}
|
|
2985
2985
|
)
|
|
2986
2986
|
] }),
|
|
2987
|
-
/* @__PURE__ */ e(Dt, { onSelect: (
|
|
2987
|
+
/* @__PURE__ */ e(Dt, { onSelect: (v, I) => d({ from: v, to: I, page: null }) }),
|
|
2988
2988
|
A ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : q.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noDocuments") }) : /* @__PURE__ */ r(Ne, { children: [
|
|
2989
2989
|
/* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-xl bg-surface ring-1 ring-line shadow-card", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
|
|
2990
|
-
/* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: W.getHeaderGroups().map((
|
|
2990
|
+
/* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: W.getHeaderGroups().map((v) => /* @__PURE__ */ e("tr", { children: v.headers.map((I) => /* @__PURE__ */ e(
|
|
2991
2991
|
"th",
|
|
2992
2992
|
{
|
|
2993
2993
|
className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
|
|
@@ -2997,11 +2997,11 @@ function vr() {
|
|
|
2997
2997
|
)
|
|
2998
2998
|
},
|
|
2999
2999
|
I.id
|
|
3000
|
-
)) },
|
|
3001
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: W.getRowModel().rows.map((
|
|
3000
|
+
)) }, v.id)) }),
|
|
3001
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: W.getRowModel().rows.map((v) => /* @__PURE__ */ e("tr", { className: "transition-colors hover:bg-surface-subtle", children: v.getVisibleCells().map((I) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5 text-fg", children: bt(
|
|
3002
3002
|
I.column.columnDef.cell,
|
|
3003
3003
|
I.getContext()
|
|
3004
|
-
) }, I.id)) },
|
|
3004
|
+
) }, I.id)) }, v.id)) })
|
|
3005
3005
|
] }) }),
|
|
3006
3006
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-fg-muted", children: [
|
|
3007
3007
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -3010,7 +3010,7 @@ function vr() {
|
|
|
3010
3010
|
/* @__PURE__ */ r("span", { className: "font-medium text-fg", children: [
|
|
3011
3011
|
D,
|
|
3012
3012
|
"–",
|
|
3013
|
-
|
|
3013
|
+
k
|
|
3014
3014
|
] }),
|
|
3015
3015
|
" ",
|
|
3016
3016
|
t("common.of"),
|
|
@@ -3024,17 +3024,17 @@ function vr() {
|
|
|
3024
3024
|
"select",
|
|
3025
3025
|
{
|
|
3026
3026
|
value: c,
|
|
3027
|
-
onChange: (
|
|
3027
|
+
onChange: (v) => b(Number(v.target.value)),
|
|
3028
3028
|
className: "h-8 rounded-md bg-surface px-2 text-sm text-fg ring-1 ring-line transition-all focus:outline-none focus:ring-2 focus:ring-brand/30",
|
|
3029
|
-
children: xr.map((
|
|
3029
|
+
children: xr.map((v) => /* @__PURE__ */ e("option", { value: v, children: v }, v))
|
|
3030
3030
|
}
|
|
3031
3031
|
)
|
|
3032
3032
|
] }),
|
|
3033
3033
|
/* @__PURE__ */ e(
|
|
3034
3034
|
"button",
|
|
3035
3035
|
{
|
|
3036
|
-
onClick: () =>
|
|
3037
|
-
disabled:
|
|
3036
|
+
onClick: () => p(Math.max(0, g - 1)),
|
|
3037
|
+
disabled: g === 0,
|
|
3038
3038
|
className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
|
|
3039
3039
|
children: t("common.prev")
|
|
3040
3040
|
}
|
|
@@ -3042,17 +3042,17 @@ function vr() {
|
|
|
3042
3042
|
/* @__PURE__ */ r("span", { className: "text-xs", children: [
|
|
3043
3043
|
t("common.page"),
|
|
3044
3044
|
" ",
|
|
3045
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children:
|
|
3045
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children: g + 1 }),
|
|
3046
3046
|
" ",
|
|
3047
3047
|
t("common.of"),
|
|
3048
3048
|
" ",
|
|
3049
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children:
|
|
3049
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children: h })
|
|
3050
3050
|
] }),
|
|
3051
3051
|
/* @__PURE__ */ e(
|
|
3052
3052
|
"button",
|
|
3053
3053
|
{
|
|
3054
|
-
onClick: () =>
|
|
3055
|
-
disabled:
|
|
3054
|
+
onClick: () => p(Math.min(h - 1, g + 1)),
|
|
3055
|
+
disabled: g >= h - 1,
|
|
3056
3056
|
className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
|
|
3057
3057
|
children: t("common.next")
|
|
3058
3058
|
}
|
|
@@ -3068,7 +3068,7 @@ function vr() {
|
|
|
3068
3068
|
const Nr = ["25", "50", "100", "200"];
|
|
3069
3069
|
function wr() {
|
|
3070
3070
|
var u;
|
|
3071
|
-
const { type: t } =
|
|
3071
|
+
const { type: t } = pt(), n = Oe(), s = (u = mt().state) == null ? void 0 : u.notice, [o] = J("per_page", 50), [i] = J("page", 1), c = i - 1, l = $e(), g = (h) => l({ page: h === 0 ? null : h + 1 }), d = (h) => l({ per_page: h, page: null }), { data: p, isLoading: m } = oe({
|
|
3072
3072
|
queryKey: ["masters", t, c, o],
|
|
3073
3073
|
queryFn: () => O.listMasters(t, {
|
|
3074
3074
|
include_disabled: 1,
|
|
@@ -3076,26 +3076,26 @@ function wr() {
|
|
|
3076
3076
|
offset: c * o
|
|
3077
3077
|
}),
|
|
3078
3078
|
enabled: !!t
|
|
3079
|
-
}), x = (
|
|
3079
|
+
}), x = (p == null ? void 0 : p.rows) ?? [], C = (p == null ? void 0 : p.total) ?? 0, b = Math.max(1, Math.ceil(C / o)), f = C === 0 ? 0 : c * o + 1, _ = Math.min(C, (c + 1) * o), A = Ce(() => {
|
|
3080
3080
|
if (!x || x.length === 0) return [];
|
|
3081
|
-
const
|
|
3081
|
+
const h = zn();
|
|
3082
3082
|
return Object.keys(x[0]).map(
|
|
3083
|
-
(
|
|
3084
|
-
header:
|
|
3083
|
+
(k) => h.accessor(k, {
|
|
3084
|
+
header: k.split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" "),
|
|
3085
3085
|
cell: (w) => {
|
|
3086
3086
|
const W = w.getValue();
|
|
3087
|
-
if (
|
|
3088
|
-
const
|
|
3087
|
+
if (k === "name") {
|
|
3088
|
+
const v = w.row.original.disabled === 1;
|
|
3089
3089
|
return /* @__PURE__ */ e(
|
|
3090
3090
|
ye,
|
|
3091
3091
|
{
|
|
3092
3092
|
to: `/masters/${t}/${W}`,
|
|
3093
|
-
className:
|
|
3093
|
+
className: v ? "font-medium text-fg-muted" : "font-medium text-brand transition-colors hover:text-brand/80",
|
|
3094
3094
|
children: W
|
|
3095
3095
|
}
|
|
3096
3096
|
);
|
|
3097
3097
|
}
|
|
3098
|
-
return
|
|
3098
|
+
return k === "disabled" ? W === 1 ? "Disabled" : "Active" : W ?? "-";
|
|
3099
3099
|
}
|
|
3100
3100
|
})
|
|
3101
3101
|
);
|
|
@@ -3106,10 +3106,10 @@ function wr() {
|
|
|
3106
3106
|
});
|
|
3107
3107
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3108
3108
|
s && /* @__PURE__ */ e("div", { className: "rounded-md bg-amber-50 px-4 py-3 text-sm text-amber-800", children: s }),
|
|
3109
|
-
/* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ e(ye, { to: `/masters/${t}/new`, children: /* @__PURE__ */ e(
|
|
3110
|
-
|
|
3109
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ e(ye, { to: `/masters/${t}/new`, children: /* @__PURE__ */ e(Z, { children: "New" }) }) }),
|
|
3110
|
+
m ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: "Loading..." }) : x.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: "No records found" }) : /* @__PURE__ */ r(Ne, { children: [
|
|
3111
3111
|
/* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-xl bg-surface ring-1 ring-line shadow-card", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
|
|
3112
|
-
/* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: q.getHeaderGroups().map((
|
|
3112
|
+
/* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: q.getHeaderGroups().map((h) => /* @__PURE__ */ e("tr", { children: h.headers.map((D) => /* @__PURE__ */ e(
|
|
3113
3113
|
"th",
|
|
3114
3114
|
{
|
|
3115
3115
|
className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
|
|
@@ -3119,18 +3119,18 @@ function wr() {
|
|
|
3119
3119
|
)
|
|
3120
3120
|
},
|
|
3121
3121
|
D.id
|
|
3122
|
-
)) },
|
|
3123
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: q.getRowModel().rows.map((
|
|
3122
|
+
)) }, h.id)) }),
|
|
3123
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: q.getRowModel().rows.map((h) => /* @__PURE__ */ e(
|
|
3124
3124
|
"tr",
|
|
3125
3125
|
{
|
|
3126
|
-
className:
|
|
3127
|
-
onClick: () => n(`/masters/${t}/${
|
|
3128
|
-
children:
|
|
3126
|
+
className: h.original.disabled === 1 ? "cursor-pointer bg-surface-subtle text-fg-muted transition-colors hover:bg-surface-subtle/80" : "cursor-pointer text-fg transition-colors hover:bg-surface-subtle",
|
|
3127
|
+
onClick: () => n(`/masters/${t}/${h.original.name}`),
|
|
3128
|
+
children: h.getVisibleCells().map((D) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5", children: bt(
|
|
3129
3129
|
D.column.columnDef.cell,
|
|
3130
3130
|
D.getContext()
|
|
3131
3131
|
) }, D.id))
|
|
3132
3132
|
},
|
|
3133
|
-
|
|
3133
|
+
h.id
|
|
3134
3134
|
)) })
|
|
3135
3135
|
] }) }),
|
|
3136
3136
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-fg-muted", children: [
|
|
@@ -3143,7 +3143,7 @@ function wr() {
|
|
|
3143
3143
|
] }),
|
|
3144
3144
|
" ",
|
|
3145
3145
|
"of ",
|
|
3146
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children:
|
|
3146
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children: C })
|
|
3147
3147
|
] }),
|
|
3148
3148
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
3149
3149
|
/* @__PURE__ */ r("label", { className: "flex items-center gap-1.5", children: [
|
|
@@ -3152,16 +3152,16 @@ function wr() {
|
|
|
3152
3152
|
"select",
|
|
3153
3153
|
{
|
|
3154
3154
|
value: o,
|
|
3155
|
-
onChange: (
|
|
3155
|
+
onChange: (h) => d(Number(h.target.value)),
|
|
3156
3156
|
className: "h-8 rounded-md bg-surface px-2 text-sm text-fg ring-1 ring-line transition-all focus:outline-none focus:ring-2 focus:ring-brand/30",
|
|
3157
|
-
children: Nr.map((
|
|
3157
|
+
children: Nr.map((h) => /* @__PURE__ */ e("option", { value: h, children: h }, h))
|
|
3158
3158
|
}
|
|
3159
3159
|
)
|
|
3160
3160
|
] }),
|
|
3161
3161
|
/* @__PURE__ */ e(
|
|
3162
3162
|
"button",
|
|
3163
3163
|
{
|
|
3164
|
-
onClick: () =>
|
|
3164
|
+
onClick: () => g(Math.max(0, c - 1)),
|
|
3165
3165
|
disabled: c === 0,
|
|
3166
3166
|
className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
|
|
3167
3167
|
children: "Prev"
|
|
@@ -3172,13 +3172,13 @@ function wr() {
|
|
|
3172
3172
|
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children: c + 1 }),
|
|
3173
3173
|
" of",
|
|
3174
3174
|
" ",
|
|
3175
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children:
|
|
3175
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-fg", children: b })
|
|
3176
3176
|
] }),
|
|
3177
3177
|
/* @__PURE__ */ e(
|
|
3178
3178
|
"button",
|
|
3179
3179
|
{
|
|
3180
|
-
onClick: () =>
|
|
3181
|
-
disabled: c >=
|
|
3180
|
+
onClick: () => g(Math.min(b - 1, c + 1)),
|
|
3181
|
+
disabled: c >= b - 1,
|
|
3182
3182
|
className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
|
|
3183
3183
|
children: "Next"
|
|
3184
3184
|
}
|
|
@@ -3254,8 +3254,8 @@ const Sr = {
|
|
|
3254
3254
|
company: "Company"
|
|
3255
3255
|
}, bn = /* @__PURE__ */ new Set(["customer", "supplier", "item", "warehouse"]);
|
|
3256
3256
|
function xn() {
|
|
3257
|
-
var
|
|
3258
|
-
const { type: t, name: n } =
|
|
3257
|
+
var k;
|
|
3258
|
+
const { type: t, name: n } = pt(), a = Oe(), s = Qe(), { t: o } = X(), i = !n || n === "new", c = kr[t ?? ""] ?? t ?? "", l = o(`masters.${t}.one`, { defaultValue: c }), g = Sr[t ?? ""] ?? [], d = (w) => o(`fields.${w.label}`, { defaultValue: w.label }), [p, m] = N({}), { data: x, isLoading: C } = oe({
|
|
3259
3259
|
queryKey: ["master", t, n],
|
|
3260
3260
|
queryFn: () => O.getMaster(t, n),
|
|
3261
3261
|
enabled: !!t && !!n && !i
|
|
@@ -3263,12 +3263,12 @@ function xn() {
|
|
|
3263
3263
|
se(() => {
|
|
3264
3264
|
if (i) {
|
|
3265
3265
|
const w = {};
|
|
3266
|
-
|
|
3266
|
+
g.forEach((W) => {
|
|
3267
3267
|
w[W.name] = W.default ?? "";
|
|
3268
|
-
}),
|
|
3269
|
-
} else x &&
|
|
3270
|
-
}, [i, x,
|
|
3271
|
-
const
|
|
3268
|
+
}), m(w);
|
|
3269
|
+
} else x && m(x);
|
|
3270
|
+
}, [i, x, g]);
|
|
3271
|
+
const b = ue({
|
|
3272
3272
|
mutationFn: (w) => O.createMaster(t, w),
|
|
3273
3273
|
onSuccess: (w) => {
|
|
3274
3274
|
s.invalidateQueries({ queryKey: ["masters", t] }), a(`/masters/${t}/${w.name}`, { replace: !0 });
|
|
@@ -3298,25 +3298,25 @@ function xn() {
|
|
|
3298
3298
|
}
|
|
3299
3299
|
}), A = () => {
|
|
3300
3300
|
if (D.length > 0) return;
|
|
3301
|
-
const w = t === "company" && !
|
|
3302
|
-
i ?
|
|
3301
|
+
const w = t === "company" && !p.name ? { ...p, name: p.company_name } : p;
|
|
3302
|
+
i ? b.mutate(w) : f.mutate(w);
|
|
3303
3303
|
}, q = () => {
|
|
3304
3304
|
window.confirm(o("masterForm.deleteConfirm", { label: l })) && _.mutate();
|
|
3305
3305
|
}, u = (w, W) => {
|
|
3306
|
-
|
|
3306
|
+
m((v) => ({ ...v, [w]: W }));
|
|
3307
3307
|
};
|
|
3308
|
-
if (!i &&
|
|
3308
|
+
if (!i && C)
|
|
3309
3309
|
return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: o("common.loading") });
|
|
3310
|
-
const
|
|
3310
|
+
const h = b.isPending || f.isPending, D = g.filter((w) => {
|
|
3311
3311
|
if (!w.required || w.readOnly || i && w.name === "name" && bn.has(t ?? "")) return !1;
|
|
3312
|
-
const W =
|
|
3312
|
+
const W = p[w.name];
|
|
3313
3313
|
return W == null || String(W).trim() === "";
|
|
3314
3314
|
});
|
|
3315
3315
|
return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
3316
3316
|
/* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
3317
|
-
/* @__PURE__ */ e(
|
|
3317
|
+
/* @__PURE__ */ e(Z, { onClick: A, disabled: h || D.length > 0, children: o(h ? "common.saving" : "common.save") }),
|
|
3318
3318
|
!i && /* @__PURE__ */ e(
|
|
3319
|
-
|
|
3319
|
+
Z,
|
|
3320
3320
|
{
|
|
3321
3321
|
variant: "danger",
|
|
3322
3322
|
onClick: q,
|
|
@@ -3325,20 +3325,20 @@ function xn() {
|
|
|
3325
3325
|
}
|
|
3326
3326
|
)
|
|
3327
3327
|
] }) }),
|
|
3328
|
-
(
|
|
3328
|
+
(b.error || f.error || _.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((k = b.error ?? f.error ?? _.error) == null ? void 0 : k.message) ?? o("common.errorOccurred") }),
|
|
3329
3329
|
D.length > 0 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.required", { fields: D.map(d).join(", ") }) }),
|
|
3330
|
-
|
|
3331
|
-
/* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children:
|
|
3332
|
-
const
|
|
3330
|
+
p.disabled === 1 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.disabledNotice", { label: l }) }),
|
|
3331
|
+
/* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: g.map((w) => {
|
|
3332
|
+
const v = w.name === "name" && !i || w.readOnly, I = w.required && !(i && w.name === "name" && bn.has(t ?? ""));
|
|
3333
3333
|
if (w.type === "select" && w.options)
|
|
3334
3334
|
return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
|
|
3335
3335
|
He,
|
|
3336
3336
|
{
|
|
3337
3337
|
label: d(w),
|
|
3338
3338
|
options: w.options,
|
|
3339
|
-
value:
|
|
3339
|
+
value: p[w.name] ?? "",
|
|
3340
3340
|
required: I,
|
|
3341
|
-
disabled:
|
|
3341
|
+
disabled: v,
|
|
3342
3342
|
onChange: (V) => u(w.name, V.target.value)
|
|
3343
3343
|
}
|
|
3344
3344
|
) }, w.name);
|
|
@@ -3350,10 +3350,10 @@ function xn() {
|
|
|
3350
3350
|
{
|
|
3351
3351
|
className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30 disabled:bg-surface-subtle disabled:text-fg-muted",
|
|
3352
3352
|
rows: 3,
|
|
3353
|
-
value:
|
|
3353
|
+
value: p[w.name] ?? "",
|
|
3354
3354
|
required: I,
|
|
3355
|
-
readOnly:
|
|
3356
|
-
disabled:
|
|
3355
|
+
readOnly: v,
|
|
3356
|
+
disabled: v,
|
|
3357
3357
|
onChange: (V) => u(w.name, V.target.value)
|
|
3358
3358
|
}
|
|
3359
3359
|
)
|
|
@@ -3366,9 +3366,9 @@ function xn() {
|
|
|
3366
3366
|
type: z,
|
|
3367
3367
|
step: w.type === "currency" ? "0.01" : void 0,
|
|
3368
3368
|
required: I,
|
|
3369
|
-
readOnly:
|
|
3370
|
-
disabled:
|
|
3371
|
-
value:
|
|
3369
|
+
readOnly: v,
|
|
3370
|
+
disabled: v,
|
|
3371
|
+
value: p[w.name] ?? "",
|
|
3372
3372
|
onChange: (V) => u(
|
|
3373
3373
|
w.name,
|
|
3374
3374
|
z === "number" ? parseFloat(V.target.value) || 0 : V.target.value
|
|
@@ -3435,58 +3435,58 @@ function Se({
|
|
|
3435
3435
|
linkDoctype: s,
|
|
3436
3436
|
readOnly: o
|
|
3437
3437
|
}) {
|
|
3438
|
-
const [i, c] = N(n ?? ""), [l,
|
|
3438
|
+
const [i, c] = N(n ?? ""), [l, g] = N([]), [d, p] = N(!1), [m, x] = N(!1), [C, b] = N({}), f = H(null), _ = H(null), A = H(null), q = H(null), u = H(!1);
|
|
3439
3439
|
se(() => {
|
|
3440
3440
|
c(n ?? "");
|
|
3441
3441
|
}, [n]);
|
|
3442
|
-
const
|
|
3442
|
+
const h = ke(() => {
|
|
3443
3443
|
if (q.current) {
|
|
3444
|
-
const
|
|
3445
|
-
|
|
3444
|
+
const v = q.current.getBoundingClientRect();
|
|
3445
|
+
b({
|
|
3446
3446
|
position: "fixed",
|
|
3447
|
-
top:
|
|
3448
|
-
left:
|
|
3449
|
-
width:
|
|
3447
|
+
top: v.bottom + 4,
|
|
3448
|
+
left: v.left,
|
|
3449
|
+
width: v.width,
|
|
3450
3450
|
zIndex: 9999
|
|
3451
3451
|
});
|
|
3452
3452
|
}
|
|
3453
3453
|
}, []), D = ke(
|
|
3454
|
-
(
|
|
3454
|
+
(v) => {
|
|
3455
3455
|
f.current && clearTimeout(f.current), f.current = setTimeout(async () => {
|
|
3456
3456
|
x(!0);
|
|
3457
3457
|
try {
|
|
3458
|
-
const I = await O.searchLink(s,
|
|
3459
|
-
|
|
3458
|
+
const I = await O.searchLink(s, v);
|
|
3459
|
+
g(I), p(!0);
|
|
3460
3460
|
} catch {
|
|
3461
|
-
|
|
3461
|
+
g([]);
|
|
3462
3462
|
} finally {
|
|
3463
3463
|
x(!1);
|
|
3464
3464
|
}
|
|
3465
3465
|
}, 300);
|
|
3466
3466
|
},
|
|
3467
3467
|
[s]
|
|
3468
|
-
),
|
|
3469
|
-
const I =
|
|
3468
|
+
), k = (v) => {
|
|
3469
|
+
const I = v.target.value;
|
|
3470
3470
|
c(I), D(I);
|
|
3471
|
-
}, w = (
|
|
3472
|
-
const I =
|
|
3473
|
-
c(I), a(I),
|
|
3471
|
+
}, w = (v) => {
|
|
3472
|
+
const I = v.name ?? v.id ?? String(v);
|
|
3473
|
+
c(I), a(I), p(!1), g([]);
|
|
3474
3474
|
}, W = () => {
|
|
3475
3475
|
setTimeout(() => {
|
|
3476
3476
|
if (u.current) {
|
|
3477
3477
|
u.current = !1;
|
|
3478
3478
|
return;
|
|
3479
3479
|
}
|
|
3480
|
-
|
|
3480
|
+
p(!1), i !== n && a(i);
|
|
3481
3481
|
}, 150);
|
|
3482
3482
|
};
|
|
3483
3483
|
return se(() => {
|
|
3484
|
-
const
|
|
3485
|
-
var V,
|
|
3484
|
+
const v = (I) => {
|
|
3485
|
+
var V, ee;
|
|
3486
3486
|
const z = I.target;
|
|
3487
|
-
(V = _.current) != null && V.contains(z) || (
|
|
3487
|
+
(V = _.current) != null && V.contains(z) || (ee = A.current) != null && ee.contains(z) || p(!1);
|
|
3488
3488
|
};
|
|
3489
|
-
return document.addEventListener("mousedown",
|
|
3489
|
+
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
3490
3490
|
}, []), o ? /* @__PURE__ */ r("div", { children: [
|
|
3491
3491
|
t && /* @__PURE__ */ e("span", { className: "mb-1.5 block text-sm font-medium text-fg", children: t }),
|
|
3492
3492
|
/* @__PURE__ */ e("span", { className: "text-sm text-fg", children: n || "—" })
|
|
@@ -3498,21 +3498,21 @@ function Se({
|
|
|
3498
3498
|
ref: q,
|
|
3499
3499
|
type: "text",
|
|
3500
3500
|
value: i,
|
|
3501
|
-
onChange:
|
|
3501
|
+
onChange: k,
|
|
3502
3502
|
onFocus: () => {
|
|
3503
|
-
|
|
3503
|
+
h(), D(i);
|
|
3504
3504
|
},
|
|
3505
3505
|
onBlur: W,
|
|
3506
3506
|
placeholder: `Search ${s}...`,
|
|
3507
3507
|
className: De(
|
|
3508
3508
|
"block h-9 w-full rounded-lg bg-surface px-3 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30",
|
|
3509
|
-
|
|
3509
|
+
m && "bg-surface-subtle"
|
|
3510
3510
|
)
|
|
3511
3511
|
}
|
|
3512
3512
|
),
|
|
3513
3513
|
d && l.length > 0 && Ca(
|
|
3514
|
-
/* @__PURE__ */ e("div", { ref: A, style:
|
|
3515
|
-
const z =
|
|
3514
|
+
/* @__PURE__ */ e("div", { ref: A, style: C, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: l.map((v, I) => {
|
|
3515
|
+
const z = v.name ?? v.id ?? String(v);
|
|
3516
3516
|
return /* @__PURE__ */ e(
|
|
3517
3517
|
"button",
|
|
3518
3518
|
{
|
|
@@ -3520,7 +3520,7 @@ function Se({
|
|
|
3520
3520
|
onMouseDown: () => {
|
|
3521
3521
|
u.current = !0;
|
|
3522
3522
|
},
|
|
3523
|
-
onClick: () => w(
|
|
3523
|
+
onClick: () => w(v),
|
|
3524
3524
|
className: "block w-full px-3 py-1.5 text-left text-sm text-fg transition-colors hover:bg-surface-subtle",
|
|
3525
3525
|
children: z
|
|
3526
3526
|
},
|
|
@@ -3532,16 +3532,16 @@ function Se({
|
|
|
3532
3532
|
] });
|
|
3533
3533
|
}
|
|
3534
3534
|
function Ir() {
|
|
3535
|
-
const { t } =
|
|
3535
|
+
const { t } = X(), [n] = J("company", ""), [a] = J("from", ""), [s] = J("to", ""), o = $e(), [i, c] = N(n), [l, g] = N(a), [d, p] = N(s), m = Me(i), x = (u) => Le(u, m), C = Ce(() => {
|
|
3536
3536
|
const u = {};
|
|
3537
3537
|
return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
|
|
3538
|
-
}, [n, a, s]), { data:
|
|
3538
|
+
}, [n, a, s]), { data: b, isLoading: f, refetch: _ } = Cr(C), A = () => {
|
|
3539
3539
|
o({
|
|
3540
3540
|
company: i || null,
|
|
3541
3541
|
from: l || null,
|
|
3542
3542
|
to: d || null
|
|
3543
3543
|
}), _();
|
|
3544
|
-
}, q =
|
|
3544
|
+
}, q = b ? b.difference === 0 : !1;
|
|
3545
3545
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3546
3546
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
3547
3547
|
/* @__PURE__ */ e(
|
|
@@ -3560,7 +3560,7 @@ function Ir() {
|
|
|
3560
3560
|
label: t("fields.From Date", { defaultValue: "From Date" }),
|
|
3561
3561
|
type: "date",
|
|
3562
3562
|
value: l,
|
|
3563
|
-
onChange: (u) =>
|
|
3563
|
+
onChange: (u) => g(u.target.value)
|
|
3564
3564
|
}
|
|
3565
3565
|
),
|
|
3566
3566
|
/* @__PURE__ */ e(
|
|
@@ -3569,15 +3569,15 @@ function Ir() {
|
|
|
3569
3569
|
label: t("fields.To Date", { defaultValue: "To Date" }),
|
|
3570
3570
|
type: "date",
|
|
3571
3571
|
value: d,
|
|
3572
|
-
onChange: (u) =>
|
|
3572
|
+
onChange: (u) => p(u.target.value)
|
|
3573
3573
|
}
|
|
3574
3574
|
),
|
|
3575
|
-
/* @__PURE__ */ e(
|
|
3575
|
+
/* @__PURE__ */ e(Z, { onClick: A, children: t("common.apply") })
|
|
3576
3576
|
] }),
|
|
3577
|
-
/* @__PURE__ */ e(Dt, { onSelect: (u,
|
|
3578
|
-
|
|
3577
|
+
/* @__PURE__ */ e(Dt, { onSelect: (u, h) => {
|
|
3578
|
+
g(u), p(h), o({ from: u, to: h });
|
|
3579
3579
|
} }),
|
|
3580
|
-
f ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : !
|
|
3580
|
+
f ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : !b || !b.rows || b.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noData") }) : /* @__PURE__ */ r($, { children: [
|
|
3581
3581
|
/* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
|
|
3582
3582
|
/* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: /* @__PURE__ */ r("tr", { children: [
|
|
3583
3583
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Account", { defaultValue: "Account" }) }),
|
|
@@ -3585,17 +3585,17 @@ function Ir() {
|
|
|
3585
3585
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Credit", { defaultValue: "Credit" }) }),
|
|
3586
3586
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Balance", { defaultValue: "Balance" }) })
|
|
3587
3587
|
] }) }),
|
|
3588
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children:
|
|
3588
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: b.rows.map((u, h) => /* @__PURE__ */ r("tr", { className: "transition-colors hover:bg-surface-subtle", children: [
|
|
3589
3589
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-fg", children: u.account }),
|
|
3590
3590
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: x(u.debit) }),
|
|
3591
3591
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: x(u.credit) }),
|
|
3592
3592
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium tabular-nums text-fg", children: x(u.balance) })
|
|
3593
|
-
] },
|
|
3593
|
+
] }, h)) }),
|
|
3594
3594
|
/* @__PURE__ */ e("tfoot", { className: "border-t border-line bg-surface-subtle font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
3595
3595
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-fg", children: t("common.total") }),
|
|
3596
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(
|
|
3597
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(
|
|
3598
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(
|
|
3596
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(b.total_debit) }),
|
|
3597
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(b.total_credit) }),
|
|
3598
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: x(b.difference) })
|
|
3599
3599
|
] }) })
|
|
3600
3600
|
] }) }),
|
|
3601
3601
|
/* @__PURE__ */ e("div", { className: "mt-4 text-center", children: q ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-emerald-50 px-4 py-1.5 text-sm font-semibold text-emerald-700 ring-1 ring-emerald-200", children: [
|
|
@@ -3613,13 +3613,13 @@ function Lr(t) {
|
|
|
3613
3613
|
}
|
|
3614
3614
|
const Br = ["25", "50", "100", "200"];
|
|
3615
3615
|
function Er() {
|
|
3616
|
-
const { t } =
|
|
3616
|
+
const { t } = X(), [n] = J("account", ""), [a] = J("party", ""), [s] = J("from", ""), [o] = J("to", ""), [i] = J("per_page", 50), [c] = J("page", 1), l = c - 1, g = $e(), d = (R) => g({ page: R === 0 ? null : R + 1 }), p = (R) => g({ per_page: R, page: null }), [m, x] = N(n), [C, b] = N(a), [f, _] = N(s), [A, q] = N(o), u = Me(), h = (R) => Le(R, u), D = Ce(() => {
|
|
3617
3617
|
const R = {};
|
|
3618
3618
|
return n && (R.account = n), a && (R.party = a), s && (R.from_date = s), o && (R.to_date = o), R.limit = String(i), R.offset = String(l * i), R;
|
|
3619
|
-
}, [n, a, s, o, i, l]), { data:
|
|
3620
|
-
|
|
3621
|
-
account:
|
|
3622
|
-
party:
|
|
3619
|
+
}, [n, a, s, o, i, l]), { data: k, isLoading: w, refetch: W } = Dr(D), v = (k == null ? void 0 : k.rows) ?? [], I = (k == null ? void 0 : k.total) ?? 0, z = Math.max(1, Math.ceil(I / i)), V = I === 0 ? 0 : l * i + 1, ee = Math.min(I, (l + 1) * i), de = () => {
|
|
3620
|
+
g({
|
|
3621
|
+
account: m || null,
|
|
3622
|
+
party: C || null,
|
|
3623
3623
|
from: f || null,
|
|
3624
3624
|
to: A || null,
|
|
3625
3625
|
page: null
|
|
@@ -3631,7 +3631,7 @@ function Er() {
|
|
|
3631
3631
|
Se,
|
|
3632
3632
|
{
|
|
3633
3633
|
label: t("fields.Account", { defaultValue: "Account" }),
|
|
3634
|
-
value:
|
|
3634
|
+
value: m,
|
|
3635
3635
|
onChange: x,
|
|
3636
3636
|
linkDoctype: "account",
|
|
3637
3637
|
readOnly: !1
|
|
@@ -3641,8 +3641,8 @@ function Er() {
|
|
|
3641
3641
|
Se,
|
|
3642
3642
|
{
|
|
3643
3643
|
label: t("fields.Party", { defaultValue: "Party" }),
|
|
3644
|
-
value:
|
|
3645
|
-
onChange:
|
|
3644
|
+
value: C,
|
|
3645
|
+
onChange: b,
|
|
3646
3646
|
linkDoctype: "customer",
|
|
3647
3647
|
readOnly: !1
|
|
3648
3648
|
}
|
|
@@ -3665,12 +3665,12 @@ function Er() {
|
|
|
3665
3665
|
onChange: (R) => q(R.target.value)
|
|
3666
3666
|
}
|
|
3667
3667
|
),
|
|
3668
|
-
/* @__PURE__ */ e(
|
|
3668
|
+
/* @__PURE__ */ e(Z, { onClick: de, children: t("common.apply") })
|
|
3669
3669
|
] }),
|
|
3670
3670
|
/* @__PURE__ */ e(Dt, { onSelect: (R, K) => {
|
|
3671
|
-
_(R), q(K),
|
|
3671
|
+
_(R), q(K), g({ from: R, to: K, page: null });
|
|
3672
3672
|
} }),
|
|
3673
|
-
w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) :
|
|
3673
|
+
w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : v.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noEntries") }) : /* @__PURE__ */ r(Ne, { children: [
|
|
3674
3674
|
/* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
3675
3675
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
|
|
3676
3676
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Date", { defaultValue: "Date" }) }),
|
|
@@ -3682,13 +3682,13 @@ function Er() {
|
|
|
3682
3682
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Voucher Type", { defaultValue: "Voucher Type" }) }),
|
|
3683
3683
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Voucher No", { defaultValue: "Voucher No" }) })
|
|
3684
3684
|
] }) }),
|
|
3685
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children:
|
|
3685
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: v.map((R, K) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3686
3686
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: Ct(R.posting_date ?? R.date) }),
|
|
3687
3687
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: R.account }),
|
|
3688
3688
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: R.party ?? "-" }),
|
|
3689
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children:
|
|
3690
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children:
|
|
3691
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children:
|
|
3689
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(R.debit) }),
|
|
3690
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(R.credit) }),
|
|
3691
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: h(R.balance) }),
|
|
3692
3692
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: R.voucher_type ?? "-" }),
|
|
3693
3693
|
/* @__PURE__ */ e("td", { className: "px-4 py-2", children: R.voucher_type && R.voucher_no ? /* @__PURE__ */ e(
|
|
3694
3694
|
ye,
|
|
@@ -3707,7 +3707,7 @@ function Er() {
|
|
|
3707
3707
|
/* @__PURE__ */ r("span", { className: "font-medium text-gray-900", children: [
|
|
3708
3708
|
V,
|
|
3709
3709
|
"–",
|
|
3710
|
-
|
|
3710
|
+
ee
|
|
3711
3711
|
] }),
|
|
3712
3712
|
" ",
|
|
3713
3713
|
t("common.of"),
|
|
@@ -3721,7 +3721,7 @@ function Er() {
|
|
|
3721
3721
|
"select",
|
|
3722
3722
|
{
|
|
3723
3723
|
value: i,
|
|
3724
|
-
onChange: (R) =>
|
|
3724
|
+
onChange: (R) => p(Number(R.target.value)),
|
|
3725
3725
|
className: "rounded border border-gray-300 bg-white px-2 py-1 text-sm",
|
|
3726
3726
|
children: Br.map((R) => /* @__PURE__ */ e("option", { value: R, children: R }, R))
|
|
3727
3727
|
}
|
|
@@ -3760,14 +3760,14 @@ function Er() {
|
|
|
3760
3760
|
] });
|
|
3761
3761
|
}
|
|
3762
3762
|
function Or() {
|
|
3763
|
-
const { t } =
|
|
3763
|
+
const { t } = X(), [n] = J("item_code", ""), [a] = J("warehouse", ""), s = $e(), [o, i] = N(n), [c, l] = N(a), g = Me(), d = (f) => Le(f, g), p = Ce(() => {
|
|
3764
3764
|
const f = {};
|
|
3765
3765
|
return n && (f.item_code = n), a && (f.warehouse = a), f;
|
|
3766
|
-
}, [n, a]), { data:
|
|
3766
|
+
}, [n, a]), { data: m, isLoading: x, refetch: C } = _r(p), b = () => {
|
|
3767
3767
|
s({
|
|
3768
3768
|
item_code: o || null,
|
|
3769
3769
|
warehouse: c || null
|
|
3770
|
-
}),
|
|
3770
|
+
}), C();
|
|
3771
3771
|
};
|
|
3772
3772
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3773
3773
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
@@ -3791,9 +3791,9 @@ function Or() {
|
|
|
3791
3791
|
readOnly: !1
|
|
3792
3792
|
}
|
|
3793
3793
|
),
|
|
3794
|
-
/* @__PURE__ */ e(
|
|
3794
|
+
/* @__PURE__ */ e(Z, { onClick: b, children: t("common.apply") })
|
|
3795
3795
|
] }),
|
|
3796
|
-
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !
|
|
3796
|
+
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noStockData") }) : /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
3797
3797
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
|
|
3798
3798
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Item Code", { defaultValue: "Item Code" }) }),
|
|
3799
3799
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Item Name", { defaultValue: "Item Name" }) }),
|
|
@@ -3802,7 +3802,7 @@ function Or() {
|
|
|
3802
3802
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Valuation Rate", { defaultValue: "Valuation Rate" }) }),
|
|
3803
3803
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Stock Value", { defaultValue: "Stock Value" }) })
|
|
3804
3804
|
] }) }),
|
|
3805
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children:
|
|
3805
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((f, _) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3806
3806
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: f.item_code }),
|
|
3807
3807
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: f.item_name }),
|
|
3808
3808
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: f.warehouse }),
|
|
@@ -3814,25 +3814,25 @@ function Or() {
|
|
|
3814
3814
|
] });
|
|
3815
3815
|
}
|
|
3816
3816
|
function qr() {
|
|
3817
|
-
const { t } =
|
|
3817
|
+
const { t } = X(), [n] = J("company", ""), [a] = J("from", ""), [s] = J("to", ""), o = $e(), [i, c] = N(n), l = Me(i), g = (u) => Le(u, l), [d, p] = N(a), [m, x] = N(s), C = Ce(() => {
|
|
3818
3818
|
const u = {};
|
|
3819
3819
|
return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
|
|
3820
|
-
}, [n, a, s]), { data:
|
|
3820
|
+
}, [n, a, s]), { data: b, isLoading: f, refetch: _ } = Pr(C), A = () => {
|
|
3821
3821
|
o({
|
|
3822
3822
|
company: i || null,
|
|
3823
3823
|
from: d || null,
|
|
3824
|
-
to:
|
|
3824
|
+
to: m || null
|
|
3825
3825
|
}), _();
|
|
3826
|
-
}, q =
|
|
3826
|
+
}, q = b && (b.income && b.income.length > 0 || b.expense && b.expense.length > 0);
|
|
3827
3827
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3828
3828
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
3829
3829
|
/* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: i, onChange: c, linkDoctype: "company", readOnly: !1 }),
|
|
3830
|
-
/* @__PURE__ */ e(Y, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: d, onChange: (u) =>
|
|
3831
|
-
/* @__PURE__ */ e(Y, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value:
|
|
3832
|
-
/* @__PURE__ */ e(
|
|
3830
|
+
/* @__PURE__ */ e(Y, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: d, onChange: (u) => p(u.target.value) }),
|
|
3831
|
+
/* @__PURE__ */ e(Y, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value: m, onChange: (u) => x(u.target.value) }),
|
|
3832
|
+
/* @__PURE__ */ e(Z, { onClick: A, children: t("common.apply") })
|
|
3833
3833
|
] }),
|
|
3834
|
-
/* @__PURE__ */ e(Dt, { onSelect: (u,
|
|
3835
|
-
|
|
3834
|
+
/* @__PURE__ */ e(Dt, { onSelect: (u, h) => {
|
|
3835
|
+
p(u), x(h), o({ from: u, to: h });
|
|
3836
3836
|
} }),
|
|
3837
3837
|
f ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : q ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3838
3838
|
/* @__PURE__ */ r($, { children: [
|
|
@@ -3842,13 +3842,13 @@ function qr() {
|
|
|
3842
3842
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
|
|
3843
3843
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
|
|
3844
3844
|
] }) }),
|
|
3845
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (
|
|
3845
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (b.income || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3846
3846
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
|
|
3847
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children:
|
|
3848
|
-
] },
|
|
3847
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
|
|
3848
|
+
] }, h)) }),
|
|
3849
3849
|
/* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
3850
3850
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalIncome") }),
|
|
3851
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children:
|
|
3851
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: g(b.total_income) })
|
|
3852
3852
|
] }) })
|
|
3853
3853
|
] })
|
|
3854
3854
|
] }),
|
|
@@ -3859,26 +3859,26 @@ function qr() {
|
|
|
3859
3859
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
|
|
3860
3860
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
|
|
3861
3861
|
] }) }),
|
|
3862
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (
|
|
3862
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (b.expense || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3863
3863
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
|
|
3864
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children:
|
|
3865
|
-
] },
|
|
3864
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
|
|
3865
|
+
] }, h)) }),
|
|
3866
3866
|
/* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
3867
3867
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalExpenses") }),
|
|
3868
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children:
|
|
3868
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: g(b.total_expense) })
|
|
3869
3869
|
] }) })
|
|
3870
3870
|
] })
|
|
3871
3871
|
] }),
|
|
3872
|
-
/* @__PURE__ */ e("div", { className: "text-center", children: /* @__PURE__ */ r("span", { className: `inline-flex items-center rounded-full px-5 py-2 text-sm font-semibold ${
|
|
3873
|
-
|
|
3872
|
+
/* @__PURE__ */ e("div", { className: "text-center", children: /* @__PURE__ */ r("span", { className: `inline-flex items-center rounded-full px-5 py-2 text-sm font-semibold ${b.net_profit >= 0 ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: [
|
|
3873
|
+
b.net_profit >= 0 ? t("reports.netProfit") : t("reports.netLoss"),
|
|
3874
3874
|
": ",
|
|
3875
|
-
|
|
3875
|
+
g(Math.abs(b.net_profit))
|
|
3876
3876
|
] }) })
|
|
3877
3877
|
] }) : /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noData") })
|
|
3878
3878
|
] });
|
|
3879
3879
|
}
|
|
3880
3880
|
function Et({ title: t, rows: n, total: a, totalLabel: s, currency: o }) {
|
|
3881
|
-
const { t: i } =
|
|
3881
|
+
const { t: i } = X(), c = (l) => Le(l, o);
|
|
3882
3882
|
return /* @__PURE__ */ r($, { children: [
|
|
3883
3883
|
/* @__PURE__ */ e("h3", { className: "mb-3 text-base font-semibold text-gray-800", children: t }),
|
|
3884
3884
|
/* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
@@ -3886,10 +3886,10 @@ function Et({ title: t, rows: n, total: a, totalLabel: s, currency: o }) {
|
|
|
3886
3886
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: i("fields.Account", { defaultValue: "Account" }) }),
|
|
3887
3887
|
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: i("fields.Balance", { defaultValue: "Balance" }) })
|
|
3888
3888
|
] }) }),
|
|
3889
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: n.map((l,
|
|
3889
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: n.map((l, g) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3890
3890
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: l.account }),
|
|
3891
3891
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: c(l.balance) })
|
|
3892
|
-
] },
|
|
3892
|
+
] }, g)) }),
|
|
3893
3893
|
/* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
3894
3894
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: s }),
|
|
3895
3895
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: c(a) })
|
|
@@ -3899,36 +3899,36 @@ function Et({ title: t, rows: n, total: a, totalLabel: s, currency: o }) {
|
|
|
3899
3899
|
}
|
|
3900
3900
|
function zr() {
|
|
3901
3901
|
var A, q, u;
|
|
3902
|
-
const { t } =
|
|
3903
|
-
const
|
|
3904
|
-
return n && (
|
|
3905
|
-
}, [n, a]), { data:
|
|
3906
|
-
s({ company: o || null, as_of_date: c || null }),
|
|
3907
|
-
}, f =
|
|
3902
|
+
const { t } = X(), [n] = J("company", ""), [a] = J("as_of_date", ""), s = $e(), [o, i] = N(n), [c, l] = N(a), g = Me(o), d = (h) => Le(h, g), p = Ce(() => {
|
|
3903
|
+
const h = {};
|
|
3904
|
+
return n && (h.company = n), a && (h.as_of_date = a), h;
|
|
3905
|
+
}, [n, a]), { data: m, isLoading: x, refetch: C } = Tr(p), b = () => {
|
|
3906
|
+
s({ company: o || null, as_of_date: c || null }), C();
|
|
3907
|
+
}, f = m && (((A = m.assets) == null ? void 0 : A.length) > 0 || ((q = m.liabilities) == null ? void 0 : q.length) > 0 || ((u = m.equity) == null ? void 0 : u.length) > 0), _ = m ? Math.abs(m.total_assets - m.total_liabilities_and_equity) < 0.01 : !1;
|
|
3908
3908
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3909
3909
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
3910
3910
|
/* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
|
|
3911
|
-
/* @__PURE__ */ e(Y, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (
|
|
3912
|
-
/* @__PURE__ */ e(
|
|
3911
|
+
/* @__PURE__ */ e(Y, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (h) => l(h.target.value) }),
|
|
3912
|
+
/* @__PURE__ */ e(Z, { onClick: b, children: t("common.apply") })
|
|
3913
3913
|
] }),
|
|
3914
|
-
/* @__PURE__ */ e(en, { onSelect: (
|
|
3915
|
-
l(
|
|
3914
|
+
/* @__PURE__ */ e(en, { onSelect: (h) => {
|
|
3915
|
+
l(h), s({ as_of_date: h });
|
|
3916
3916
|
} }),
|
|
3917
3917
|
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : f ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3918
|
-
/* @__PURE__ */ e(Et, { title: t("reports.assets"), rows:
|
|
3919
|
-
/* @__PURE__ */ e(Et, { title: t("reports.liabilities"), rows:
|
|
3920
|
-
/* @__PURE__ */ e(Et, { title: t("reports.equity"), rows:
|
|
3918
|
+
/* @__PURE__ */ e(Et, { title: t("reports.assets"), rows: m.assets || [], total: m.total_assets, totalLabel: t("reports.totalAssets"), currency: g }),
|
|
3919
|
+
/* @__PURE__ */ e(Et, { title: t("reports.liabilities"), rows: m.liabilities || [], total: m.total_liabilities, totalLabel: t("reports.totalLiabilities"), currency: g }),
|
|
3920
|
+
/* @__PURE__ */ e(Et, { title: t("reports.equity"), rows: m.equity || [], total: m.total_equity, totalLabel: t("reports.totalEquity"), currency: g }),
|
|
3921
3921
|
/* @__PURE__ */ e($, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
3922
3922
|
/* @__PURE__ */ r("div", { className: "text-sm", children: [
|
|
3923
3923
|
/* @__PURE__ */ r("div", { className: "text-gray-500", children: [
|
|
3924
3924
|
t("reports.totalAssets"),
|
|
3925
3925
|
": ",
|
|
3926
|
-
/* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(
|
|
3926
|
+
/* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(m.total_assets) })
|
|
3927
3927
|
] }),
|
|
3928
3928
|
/* @__PURE__ */ r("div", { className: "text-gray-500", children: [
|
|
3929
3929
|
t("reports.totalLiabilitiesEquity"),
|
|
3930
3930
|
": ",
|
|
3931
|
-
/* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(
|
|
3931
|
+
/* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(m.total_liabilities_and_equity) })
|
|
3932
3932
|
] })
|
|
3933
3933
|
] }),
|
|
3934
3934
|
_ ? /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-green-100 px-4 py-1.5 text-sm font-semibold text-green-800", children: t("reports.balanced") }) : /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-red-100 px-4 py-1.5 text-sm font-semibold text-red-800", children: t("reports.imbalanced") })
|
|
@@ -3937,22 +3937,22 @@ function zr() {
|
|
|
3937
3937
|
] });
|
|
3938
3938
|
}
|
|
3939
3939
|
function Fr() {
|
|
3940
|
-
const { t } =
|
|
3940
|
+
const { t } = X(), [n] = J("company", ""), [a] = J("as_of_date", ""), s = $e(), [o, i] = N(n), [c, l] = N(a), g = Me(o), d = (f) => Le(f, g), p = Ce(() => {
|
|
3941
3941
|
const f = {};
|
|
3942
3942
|
return n && (f.company = n), a && (f.as_of_date = a), f;
|
|
3943
|
-
}, [n, a]), { data:
|
|
3944
|
-
s({ company: o || null, as_of_date: c || null }),
|
|
3943
|
+
}, [n, a]), { data: m, isLoading: x, refetch: C } = Ar(p), b = () => {
|
|
3944
|
+
s({ company: o || null, as_of_date: c || null }), C();
|
|
3945
3945
|
};
|
|
3946
3946
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3947
3947
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
3948
3948
|
/* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
|
|
3949
3949
|
/* @__PURE__ */ e(Y, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (f) => l(f.target.value) }),
|
|
3950
|
-
/* @__PURE__ */ e(
|
|
3950
|
+
/* @__PURE__ */ e(Z, { onClick: b, children: t("common.apply") })
|
|
3951
3951
|
] }),
|
|
3952
3952
|
/* @__PURE__ */ e(en, { onSelect: (f) => {
|
|
3953
3953
|
l(f), s({ as_of_date: f });
|
|
3954
3954
|
} }),
|
|
3955
|
-
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !
|
|
3955
|
+
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noReceivables") }) : /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
3956
3956
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
|
|
3957
3957
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Invoice", { defaultValue: "Invoice" }) }),
|
|
3958
3958
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Customer", { defaultValue: "Customer" }) }),
|
|
@@ -3964,7 +3964,7 @@ function Fr() {
|
|
|
3964
3964
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
|
|
3965
3965
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
|
|
3966
3966
|
] }) }),
|
|
3967
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children:
|
|
3967
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((f, _) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
3968
3968
|
/* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
|
|
3969
3969
|
ye,
|
|
3970
3970
|
{
|
|
@@ -3984,33 +3984,33 @@ function Fr() {
|
|
|
3984
3984
|
] }, _)) }),
|
|
3985
3985
|
/* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
3986
3986
|
/* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
|
|
3987
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
3988
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
3989
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
3990
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
3991
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
3992
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(
|
|
3987
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.outstanding) }),
|
|
3988
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.current) }),
|
|
3989
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b1_30) }),
|
|
3990
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b31_60) }),
|
|
3991
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b61_90) }),
|
|
3992
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(m.totals.b90_plus) })
|
|
3993
3993
|
] }) })
|
|
3994
3994
|
] }) }) })
|
|
3995
3995
|
] });
|
|
3996
3996
|
}
|
|
3997
3997
|
function Mr() {
|
|
3998
|
-
const { t } =
|
|
3998
|
+
const { t } = X(), [n] = J("company", ""), [a] = J("as_of_date", ""), s = $e(), [o, i] = N(n), [c, l] = N(a), g = Me(o), d = (f) => Le(f, g), p = Ce(() => {
|
|
3999
3999
|
const f = {};
|
|
4000
4000
|
return n && (f.company = n), a && (f.as_of_date = a), f;
|
|
4001
|
-
}, [n, a]), { data:
|
|
4002
|
-
s({ company: o || null, as_of_date: c || null }),
|
|
4001
|
+
}, [n, a]), { data: m, isLoading: x, refetch: C } = Rr(p), b = () => {
|
|
4002
|
+
s({ company: o || null, as_of_date: c || null }), C();
|
|
4003
4003
|
};
|
|
4004
4004
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
4005
4005
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
4006
4006
|
/* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
|
|
4007
4007
|
/* @__PURE__ */ e(Y, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (f) => l(f.target.value) }),
|
|
4008
|
-
/* @__PURE__ */ e(
|
|
4008
|
+
/* @__PURE__ */ e(Z, { onClick: b, children: t("common.apply") })
|
|
4009
4009
|
] }),
|
|
4010
4010
|
/* @__PURE__ */ e(en, { onSelect: (f) => {
|
|
4011
4011
|
l(f), s({ as_of_date: f });
|
|
4012
4012
|
} }),
|
|
4013
|
-
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !
|
|
4013
|
+
x ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noPayables") }) : /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
4014
4014
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
|
|
4015
4015
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Invoice", { defaultValue: "Invoice" }) }),
|
|
4016
4016
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Supplier", { defaultValue: "Supplier" }) }),
|
|
@@ -4022,7 +4022,7 @@ function Mr() {
|
|
|
4022
4022
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
|
|
4023
4023
|
/* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
|
|
4024
4024
|
] }) }),
|
|
4025
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children:
|
|
4025
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((f, _) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
|
|
4026
4026
|
/* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
|
|
4027
4027
|
ye,
|
|
4028
4028
|
{
|
|
@@ -4042,12 +4042,12 @@ function Mr() {
|
|
|
4042
4042
|
] }, _)) }),
|
|
4043
4043
|
/* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
|
|
4044
4044
|
/* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
|
|
4045
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
4046
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
4047
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
4048
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
4049
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(
|
|
4050
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(
|
|
4045
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.outstanding) }),
|
|
4046
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.current) }),
|
|
4047
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b1_30) }),
|
|
4048
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b31_60) }),
|
|
4049
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b61_90) }),
|
|
4050
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(m.totals.b90_plus) })
|
|
4051
4051
|
] }) })
|
|
4052
4052
|
] }) }) })
|
|
4053
4053
|
] });
|
|
@@ -4147,13 +4147,13 @@ return {
|
|
|
4147
4147
|
}
|
|
4148
4148
|
const Yn = Ur();
|
|
4149
4149
|
function Vr() {
|
|
4150
|
-
const t = Oe(), { sessions: n, createSession: a } = tt(), [s] = J("report_id", ""), [o] = J("metric", ""), [i] = J("group_by", ""), [c] = J("from", ""), [l] = J("to", ""), [
|
|
4150
|
+
const t = Oe(), { sessions: n, createSession: a } = tt(), [s] = J("report_id", ""), [o] = J("metric", ""), [i] = J("group_by", ""), [c] = J("from", ""), [l] = J("to", ""), [g] = J("company", ""), [d, p] = N(Yn), [m, x] = N([]), [C, b] = N(null), [f, _] = N(""), [A, q] = N(!1), [u, h] = N(!1), [D, k] = N(""), w = H(null), W = H(""), v = H(""), I = H(0), z = Ce(() => !o || !i ? "" : JSON.stringify(Kr({
|
|
4151
4151
|
metric: o,
|
|
4152
4152
|
groupBy: i,
|
|
4153
4153
|
fromDate: c || void 0,
|
|
4154
4154
|
toDate: l || void 0,
|
|
4155
|
-
company:
|
|
4156
|
-
}), null, 2), [o, i, c, l,
|
|
4155
|
+
company: g || void 0
|
|
4156
|
+
}), null, 2), [o, i, c, l, g]), V = async (K) => {
|
|
4157
4157
|
var ge;
|
|
4158
4158
|
const ie = ++I.current, le = () => I.current === ie;
|
|
4159
4159
|
_(""), q(!0);
|
|
@@ -4177,33 +4177,33 @@ function Vr() {
|
|
|
4177
4177
|
});
|
|
4178
4178
|
});
|
|
4179
4179
|
if (!le()) return;
|
|
4180
|
-
|
|
4180
|
+
b(Be);
|
|
4181
4181
|
} catch (T) {
|
|
4182
4182
|
if (!le()) return;
|
|
4183
|
-
|
|
4183
|
+
b(null), _(T instanceof Error ? T.message : String(T));
|
|
4184
4184
|
} finally {
|
|
4185
4185
|
le() && q(!1);
|
|
4186
4186
|
}
|
|
4187
4187
|
};
|
|
4188
4188
|
se(() => {
|
|
4189
4189
|
let K = !1;
|
|
4190
|
-
return s ? W.current === s ? void 0 : (
|
|
4190
|
+
return s ? W.current === s ? void 0 : (h(!0), _(""), O.getRuntimeDraft(s).then((ie) => {
|
|
4191
4191
|
if (K) return;
|
|
4192
4192
|
const le = JSON.stringify(ie.definition, null, 2);
|
|
4193
|
-
return W.current = s,
|
|
4193
|
+
return W.current = s, v.current = le, k(ie.source_chat_session_id || ""), p(le), V(le);
|
|
4194
4194
|
}).catch((ie) => {
|
|
4195
|
-
K || (
|
|
4195
|
+
K || (b(null), _(ie instanceof Error ? ie.message : String(ie)));
|
|
4196
4196
|
}).finally(() => {
|
|
4197
|
-
K ||
|
|
4197
|
+
K || h(!1);
|
|
4198
4198
|
}), () => {
|
|
4199
4199
|
K = !0;
|
|
4200
|
-
}) : (W.current = "",
|
|
4200
|
+
}) : (W.current = "", v.current = "", k(""), z && (v.current = z, p(z), V(z)), () => {
|
|
4201
4201
|
K = !0;
|
|
4202
4202
|
});
|
|
4203
4203
|
}, [s, z]);
|
|
4204
|
-
const
|
|
4204
|
+
const ee = !!(!s && z), de = Ce(() => Wr(C), [C]), R = async () => {
|
|
4205
4205
|
var ce;
|
|
4206
|
-
const K = d.trim() !==
|
|
4206
|
+
const K = d.trim() !== v.current.trim(), ie = s || "unsaved-runtime-report", le = m.map((ae) => ({
|
|
4207
4207
|
name: ae.name,
|
|
4208
4208
|
dataset: ae.dataset,
|
|
4209
4209
|
row_count: ae.row_count,
|
|
@@ -4248,13 +4248,13 @@ function Vr() {
|
|
|
4248
4248
|
s ? /* @__PURE__ */ r("div", { className: "text-xs text-gray-500", children: [
|
|
4249
4249
|
"Loaded draft: ",
|
|
4250
4250
|
s
|
|
4251
|
-
] }) :
|
|
4252
|
-
s ? /* @__PURE__ */ e(
|
|
4253
|
-
/* @__PURE__ */ e(
|
|
4251
|
+
] }) : ee ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-500", children: "Loaded runtime report from legacy URL filters." }) : null,
|
|
4252
|
+
s ? /* @__PURE__ */ e(Z, { variant: "secondary", onClick: () => void R(), children: "Fix In Chat" }) : null,
|
|
4253
|
+
/* @__PURE__ */ e(Z, { onClick: () => void V(), disabled: A, children: A ? "Running..." : "Run Report" })
|
|
4254
4254
|
] })
|
|
4255
4255
|
] }) }),
|
|
4256
|
-
u ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : f ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: f }) }) :
|
|
4257
|
-
|
|
4256
|
+
u ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : f ? /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: f }) }) : C ? /* @__PURE__ */ e(jr, { output: C }) : /* @__PURE__ */ e($, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Edit the runtime JSON below or open a draft from chat, then run the report." }) }),
|
|
4257
|
+
m.length > 0 && /* @__PURE__ */ e($, { title: "Fetched Datasets", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: m.map((K) => /* @__PURE__ */ r("div", { className: "rounded-md border border-gray-200 p-4", children: [
|
|
4258
4258
|
/* @__PURE__ */ r("div", { className: "flex items-baseline justify-between gap-4", children: [
|
|
4259
4259
|
/* @__PURE__ */ r("div", { children: [
|
|
4260
4260
|
/* @__PURE__ */ e("div", { className: "font-medium text-gray-900", children: K.name }),
|
|
@@ -4275,7 +4275,7 @@ function Vr() {
|
|
|
4275
4275
|
{
|
|
4276
4276
|
className: "min-h-[520px] w-full rounded-md border border-gray-300 p-3 font-mono text-xs text-gray-900 outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500",
|
|
4277
4277
|
value: d,
|
|
4278
|
-
onChange: (K) =>
|
|
4278
|
+
onChange: (K) => p(K.target.value),
|
|
4279
4279
|
spellCheck: !1
|
|
4280
4280
|
}
|
|
4281
4281
|
)
|
|
@@ -4296,17 +4296,17 @@ function jr({ output: t }) {
|
|
|
4296
4296
|
] }) }),
|
|
4297
4297
|
(s = t.kpis) != null && s.length ? /* @__PURE__ */ e("div", { className: "mt-4 grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: t.kpis.map((i, c) => /* @__PURE__ */ r("div", { className: "rounded-md border border-gray-200 p-4", children: [
|
|
4298
4298
|
/* @__PURE__ */ e("div", { className: "text-sm text-gray-500", children: i.label }),
|
|
4299
|
-
/* @__PURE__ */ e("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children:
|
|
4299
|
+
/* @__PURE__ */ e("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: dt(i.value, i.format) })
|
|
4300
4300
|
] }, `${i.label}-${c}`)) }) : null
|
|
4301
4301
|
] }),
|
|
4302
4302
|
(o = t.charts) == null ? void 0 : o.map((i, c) => {
|
|
4303
|
-
const l = i.dataTable ? a.get(i.dataTable) : void 0,
|
|
4304
|
-
if (!
|
|
4303
|
+
const l = i.dataTable ? a.get(i.dataTable) : void 0, g = i.data ?? (l == null ? void 0 : l.rows) ?? [];
|
|
4304
|
+
if (!g.length)
|
|
4305
4305
|
return /* @__PURE__ */ e($, { title: i.title, children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: "Chart has no usable data." }) }, i.id || `chart_${c + 1}`);
|
|
4306
|
-
const d = i.type === "pie" ? [] :
|
|
4306
|
+
const d = i.type === "pie" ? [] : g.map((x) => String(x[i.x] ?? "")), p = Yr(d), m = Math.max(320, 200 + p.axisHeight);
|
|
4307
4307
|
return /* @__PURE__ */ r($, { children: [
|
|
4308
4308
|
/* @__PURE__ */ e("div", { className: "pb-3 text-sm font-semibold text-gray-700", children: i.title }),
|
|
4309
|
-
/* @__PURE__ */ e("div", { style: { height:
|
|
4309
|
+
/* @__PURE__ */ e("div", { style: { height: m }, className: "w-full", children: /* @__PURE__ */ e(Da, { width: "100%", height: "100%", children: i.type === "line" ? /* @__PURE__ */ r(_a, { data: g, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
|
|
4310
4310
|
/* @__PURE__ */ e(an, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
|
|
4311
4311
|
/* @__PURE__ */ e(
|
|
4312
4312
|
rn,
|
|
@@ -4314,18 +4314,18 @@ function jr({ output: t }) {
|
|
|
4314
4314
|
dataKey: i.x,
|
|
4315
4315
|
tick: { fill: "#6b7280", fontSize: 12 },
|
|
4316
4316
|
interval: 0,
|
|
4317
|
-
angle:
|
|
4318
|
-
textAnchor:
|
|
4319
|
-
height:
|
|
4317
|
+
angle: p.angle,
|
|
4318
|
+
textAnchor: p.angle === 0 ? "middle" : "end",
|
|
4319
|
+
height: p.axisHeight
|
|
4320
4320
|
}
|
|
4321
4321
|
),
|
|
4322
4322
|
/* @__PURE__ */ e(sn, { tick: { fill: "#6b7280", fontSize: 12 }, tickFormatter: Nn }),
|
|
4323
|
-
/* @__PURE__ */ e(It, { formatter: (x) =>
|
|
4323
|
+
/* @__PURE__ */ e(It, { formatter: (x) => dt(x, Ot(l, i.y)) }),
|
|
4324
4324
|
/* @__PURE__ */ e(Pa, { type: "monotone", dataKey: i.y, stroke: "#3b82f6", strokeWidth: 2, dot: { r: 3 } })
|
|
4325
4325
|
] }) : i.type === "pie" ? /* @__PURE__ */ r(Ta, { children: [
|
|
4326
|
-
/* @__PURE__ */ e(It, { formatter: (x) =>
|
|
4327
|
-
/* @__PURE__ */ e(Aa, { data:
|
|
4328
|
-
] }) : /* @__PURE__ */ r(Ia, { data:
|
|
4326
|
+
/* @__PURE__ */ e(It, { formatter: (x) => dt(x, Ot(l, i.y)) }),
|
|
4327
|
+
/* @__PURE__ */ e(Aa, { data: g, dataKey: i.y, nameKey: i.x, outerRadius: 110, children: g.map((x, C) => /* @__PURE__ */ e(Ra, { fill: wn[C % wn.length] }, C)) })
|
|
4328
|
+
] }) : /* @__PURE__ */ r(Ia, { data: g, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
|
|
4329
4329
|
/* @__PURE__ */ e(an, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
|
|
4330
4330
|
/* @__PURE__ */ e(
|
|
4331
4331
|
rn,
|
|
@@ -4333,20 +4333,20 @@ function jr({ output: t }) {
|
|
|
4333
4333
|
dataKey: i.x,
|
|
4334
4334
|
tick: { fill: "#6b7280", fontSize: 12 },
|
|
4335
4335
|
interval: 0,
|
|
4336
|
-
angle:
|
|
4337
|
-
textAnchor:
|
|
4338
|
-
height:
|
|
4336
|
+
angle: p.angle,
|
|
4337
|
+
textAnchor: p.angle === 0 ? "middle" : "end",
|
|
4338
|
+
height: p.axisHeight
|
|
4339
4339
|
}
|
|
4340
4340
|
),
|
|
4341
4341
|
/* @__PURE__ */ e(sn, { tick: { fill: "#6b7280", fontSize: 12 }, tickFormatter: Nn }),
|
|
4342
|
-
/* @__PURE__ */ e(It, { formatter: (x) =>
|
|
4342
|
+
/* @__PURE__ */ e(It, { formatter: (x) => dt(x, Ot(l, i.y)) }),
|
|
4343
4343
|
/* @__PURE__ */ e(La, { dataKey: i.y, fill: "#3b82f6", radius: [4, 4, 0, 0] })
|
|
4344
4344
|
] }) }) })
|
|
4345
4345
|
] }, i.id || `chart_${c + 1}`);
|
|
4346
4346
|
}),
|
|
4347
4347
|
n.map((i) => /* @__PURE__ */ e($, { title: i.title, children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
|
|
4348
4348
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ e("tr", { children: i.columns.map((c) => /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: c.label }, c.key)) }) }),
|
|
4349
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.rows.map((c, l) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: i.columns.map((
|
|
4349
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.rows.map((c, l) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: i.columns.map((g) => /* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-gray-900", children: dt(c[g.key], g.type) }, g.key)) }, l)) })
|
|
4350
4350
|
] }) }) }, i.id))
|
|
4351
4351
|
] });
|
|
4352
4352
|
}
|
|
@@ -4551,7 +4551,7 @@ function Ot(t, n) {
|
|
|
4551
4551
|
var a, s;
|
|
4552
4552
|
return ((a = t == null ? void 0 : t.columns.find((o) => o.key === n)) == null ? void 0 : a.type) || ((s = t == null ? void 0 : t.columns.find((o) => o.key === n)) == null ? void 0 : s.format);
|
|
4553
4553
|
}
|
|
4554
|
-
function
|
|
4554
|
+
function dt(t, n) {
|
|
4555
4555
|
return n === "currency" ? Le(Ee(t)) : n === "percent" ? `${(Ee(t) * 100).toFixed(1)}%` : n === "number" ? Mt(Ee(t)) : n === "date" ? Ct(String(t ?? "")) : typeof t == "number" ? Mt(t) : String(t ?? "");
|
|
4556
4556
|
}
|
|
4557
4557
|
function Nn(t) {
|
|
@@ -4579,7 +4579,7 @@ function Xr() {
|
|
|
4579
4579
|
const t = Qe(), { data: n, isLoading: a } = oe({
|
|
4580
4580
|
queryKey: ["setup-status"],
|
|
4581
4581
|
queryFn: () => O.setupStatus()
|
|
4582
|
-
}), [s, o] = N(""), [i, c] = N("USD"), [l,
|
|
4582
|
+
}), [s, o] = N(""), [i, c] = N("USD"), [l, g] = N({
|
|
4583
4583
|
address: "",
|
|
4584
4584
|
city: "",
|
|
4585
4585
|
zip_code: "",
|
|
@@ -4587,7 +4587,7 @@ function Xr() {
|
|
|
4587
4587
|
email: "",
|
|
4588
4588
|
phone: "",
|
|
4589
4589
|
tax_id: ""
|
|
4590
|
-
}), d = (
|
|
4590
|
+
}), d = (k) => (w) => g((W) => ({ ...W, [k]: w.target.value })), [p, m] = N("quick"), [x, C] = N(!1), [b, f] = N(null), _ = ue({
|
|
4591
4591
|
mutationFn: () => O.createCompany({ name: s, currency: i, ...l })
|
|
4592
4592
|
}), A = ue({
|
|
4593
4593
|
mutationFn: () => O.seedDemo()
|
|
@@ -4596,11 +4596,11 @@ function Xr() {
|
|
|
4596
4596
|
}), u = async () => {
|
|
4597
4597
|
if (s.trim())
|
|
4598
4598
|
try {
|
|
4599
|
-
if (await _.mutateAsync(),
|
|
4600
|
-
const
|
|
4601
|
-
f(
|
|
4602
|
-
} else
|
|
4603
|
-
t.invalidateQueries({ queryKey: ["setup-status"] }),
|
|
4599
|
+
if (await _.mutateAsync(), p === "history") {
|
|
4600
|
+
const k = await q.mutateAsync();
|
|
4601
|
+
f(k.stats);
|
|
4602
|
+
} else p === "quick" && await A.mutateAsync();
|
|
4603
|
+
t.invalidateQueries({ queryKey: ["setup-status"] }), C(!0);
|
|
4604
4604
|
} catch {
|
|
4605
4605
|
}
|
|
4606
4606
|
};
|
|
@@ -4608,23 +4608,23 @@ function Xr() {
|
|
|
4608
4608
|
return /* @__PURE__ */ e("p", { className: "text-gray-500", children: "Loading..." });
|
|
4609
4609
|
if (n != null && n.setup_complete && !x)
|
|
4610
4610
|
return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
4611
|
-
/* @__PURE__ */ e($, { title: "Companies", children: n.companies && n.companies.length > 0 ? /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100", children: n.companies.map((
|
|
4611
|
+
/* @__PURE__ */ e($, { title: "Companies", children: n.companies && n.companies.length > 0 ? /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100", children: n.companies.map((k, w) => /* @__PURE__ */ e("li", { className: "py-3", children: /* @__PURE__ */ e(es, { company: k }) }, w)) }) : /* @__PURE__ */ e("p", { className: "text-gray-400", children: "No companies found" }) }),
|
|
4612
4612
|
/* @__PURE__ */ e(ye, { to: "/", className: "text-blue-600 hover:text-blue-800 text-sm font-medium", children: "Go to Dashboard" })
|
|
4613
4613
|
] });
|
|
4614
4614
|
if (x)
|
|
4615
4615
|
return /* @__PURE__ */ e("div", { className: "space-y-6", children: /* @__PURE__ */ e($, { children: /* @__PURE__ */ r("div", { className: "py-8 text-center", children: [
|
|
4616
4616
|
/* @__PURE__ */ e("p", { className: "text-lg font-semibold text-green-700", children: "Setup complete!" }),
|
|
4617
|
-
/* @__PURE__ */ e("p", { className: "mt-2 text-sm text-gray-500", children:
|
|
4618
|
-
|
|
4617
|
+
/* @__PURE__ */ e("p", { className: "mt-2 text-sm text-gray-500", children: p === "history" ? "Your company has been created and three years of history has been simulated." : p === "quick" ? "Your company has been created and demo data has been seeded." : "Your company has been created. No demo data was added." }),
|
|
4618
|
+
b && /* @__PURE__ */ r("div", { className: "mx-auto mt-6 max-w-sm text-left", children: [
|
|
4619
4619
|
/* @__PURE__ */ e("p", { className: "mb-2 text-sm font-medium text-gray-700", children: "Generated documents:" }),
|
|
4620
|
-
/* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100 text-sm", children: Object.entries(
|
|
4621
|
-
/* @__PURE__ */ e("span", { className: "text-gray-600", children:
|
|
4620
|
+
/* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100 text-sm", children: Object.entries(b).sort(([k], [w]) => k.localeCompare(w)).map(([k, w]) => /* @__PURE__ */ r("li", { className: "flex justify-between py-1", children: [
|
|
4621
|
+
/* @__PURE__ */ e("span", { className: "text-gray-600", children: k.replace(/_/g, " ") }),
|
|
4622
4622
|
/* @__PURE__ */ e("span", { className: "font-mono text-gray-900", children: w.toLocaleString() })
|
|
4623
|
-
] },
|
|
4623
|
+
] }, k)) })
|
|
4624
4624
|
] }),
|
|
4625
|
-
/* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(ye, { to: "/", children: /* @__PURE__ */ e(
|
|
4625
|
+
/* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(ye, { to: "/", children: /* @__PURE__ */ e(Z, { children: "Go to Dashboard" }) }) })
|
|
4626
4626
|
] }) }) });
|
|
4627
|
-
const
|
|
4627
|
+
const h = _.isPending || A.isPending || q.isPending, D = _.error ?? A.error ?? q.error;
|
|
4628
4628
|
return /* @__PURE__ */ r("div", { className: "mx-auto max-w-lg space-y-6", children: [
|
|
4629
4629
|
/* @__PURE__ */ e("p", { className: "text-sm text-gray-500", children: "Set up your first company to get started." }),
|
|
4630
4630
|
D && /* @__PURE__ */ e("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: D.message ?? "An error occurred during setup" }),
|
|
@@ -4634,7 +4634,7 @@ function Xr() {
|
|
|
4634
4634
|
{
|
|
4635
4635
|
label: "Company Name",
|
|
4636
4636
|
value: s,
|
|
4637
|
-
onChange: (
|
|
4637
|
+
onChange: (k) => o(k.target.value),
|
|
4638
4638
|
placeholder: "e.g. My Company Ltd",
|
|
4639
4639
|
required: !0
|
|
4640
4640
|
}
|
|
@@ -4645,7 +4645,7 @@ function Xr() {
|
|
|
4645
4645
|
label: "Currency",
|
|
4646
4646
|
options: Zr,
|
|
4647
4647
|
value: i,
|
|
4648
|
-
onChange: (
|
|
4648
|
+
onChange: (k) => c(k.target.value)
|
|
4649
4649
|
}
|
|
4650
4650
|
),
|
|
4651
4651
|
/* @__PURE__ */ r("fieldset", { className: "space-y-3", children: [
|
|
@@ -4682,8 +4682,8 @@ function Xr() {
|
|
|
4682
4682
|
type: "radio",
|
|
4683
4683
|
name: "seed-mode",
|
|
4684
4684
|
value: "quick",
|
|
4685
|
-
checked:
|
|
4686
|
-
onChange: () =>
|
|
4685
|
+
checked: p === "quick",
|
|
4686
|
+
onChange: () => m("quick"),
|
|
4687
4687
|
className: "mt-1"
|
|
4688
4688
|
}
|
|
4689
4689
|
),
|
|
@@ -4699,8 +4699,8 @@ function Xr() {
|
|
|
4699
4699
|
type: "radio",
|
|
4700
4700
|
name: "seed-mode",
|
|
4701
4701
|
value: "history",
|
|
4702
|
-
checked:
|
|
4703
|
-
onChange: () =>
|
|
4702
|
+
checked: p === "history",
|
|
4703
|
+
onChange: () => m("history"),
|
|
4704
4704
|
className: "mt-1"
|
|
4705
4705
|
}
|
|
4706
4706
|
),
|
|
@@ -4716,8 +4716,8 @@ function Xr() {
|
|
|
4716
4716
|
type: "radio",
|
|
4717
4717
|
name: "seed-mode",
|
|
4718
4718
|
value: "none",
|
|
4719
|
-
checked:
|
|
4720
|
-
onChange: () =>
|
|
4719
|
+
checked: p === "none",
|
|
4720
|
+
onChange: () => m("none"),
|
|
4721
4721
|
className: "mt-1"
|
|
4722
4722
|
}
|
|
4723
4723
|
),
|
|
@@ -4728,11 +4728,11 @@ function Xr() {
|
|
|
4728
4728
|
] })
|
|
4729
4729
|
] }),
|
|
4730
4730
|
/* @__PURE__ */ e("div", { className: "pt-2", children: /* @__PURE__ */ e(
|
|
4731
|
-
|
|
4731
|
+
Z,
|
|
4732
4732
|
{
|
|
4733
4733
|
onClick: u,
|
|
4734
|
-
disabled:
|
|
4735
|
-
children:
|
|
4734
|
+
disabled: h || !s.trim(),
|
|
4735
|
+
children: h ? p === "history" ? "Simulating three years..." : "Setting up..." : p === "history" ? "Create Company & Simulate History" : p === "quick" ? "Create Company & Seed Demo Data" : "Create Company"
|
|
4736
4736
|
}
|
|
4737
4737
|
) })
|
|
4738
4738
|
] }) })
|
|
@@ -4917,9 +4917,9 @@ const ts = [
|
|
|
4917
4917
|
}
|
|
4918
4918
|
];
|
|
4919
4919
|
function ns() {
|
|
4920
|
-
const t = Oe(), { t: n } =
|
|
4921
|
-
var
|
|
4922
|
-
let l = ((
|
|
4920
|
+
const t = Oe(), { t: n } = X(), { sessions: a, createSession: s } = tt(), o = async (c) => {
|
|
4921
|
+
var g;
|
|
4922
|
+
let l = ((g = a[0]) == null ? void 0 : g.id) || "";
|
|
4923
4923
|
if (!l)
|
|
4924
4924
|
try {
|
|
4925
4925
|
l = (await s()).id;
|
|
@@ -4987,7 +4987,7 @@ function ns() {
|
|
|
4987
4987
|
] }) });
|
|
4988
4988
|
}
|
|
4989
4989
|
function as() {
|
|
4990
|
-
const { t } =
|
|
4990
|
+
const { t } = X(), n = (a) => t(`tutorial.chips.${a}`, { defaultValue: a });
|
|
4991
4991
|
return /* @__PURE__ */ r($, { children: [
|
|
4992
4992
|
/* @__PURE__ */ e("h3", { className: "text-base font-semibold text-gray-900 mb-3", children: t("tutorial.flowTitle") }),
|
|
4993
4993
|
/* @__PURE__ */ r("div", { className: "space-y-4 text-sm text-gray-600", children: [
|
|
@@ -5058,7 +5058,7 @@ function as() {
|
|
|
5058
5058
|
] });
|
|
5059
5059
|
}
|
|
5060
5060
|
function rs() {
|
|
5061
|
-
const { t } =
|
|
5061
|
+
const { t } = X(), n = (a) => t(`tutorial.chips.${a}`, { defaultValue: a });
|
|
5062
5062
|
return /* @__PURE__ */ r($, { children: [
|
|
5063
5063
|
/* @__PURE__ */ e("h3", { className: "text-base font-semibold text-gray-900 mb-3", children: t("tutorial.lifecycleTitle") }),
|
|
5064
5064
|
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm text-gray-600", children: [
|
|
@@ -5094,7 +5094,7 @@ function rs() {
|
|
|
5094
5094
|
] });
|
|
5095
5095
|
}
|
|
5096
5096
|
function ss() {
|
|
5097
|
-
const { t } =
|
|
5097
|
+
const { t } = X();
|
|
5098
5098
|
return /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl space-y-6", children: [
|
|
5099
5099
|
/* @__PURE__ */ r("div", { children: [
|
|
5100
5100
|
/* @__PURE__ */ e("h2", { className: "text-xl font-semibold text-gray-900", children: t("tutorial.pageTitle") }),
|
|
@@ -5212,22 +5212,22 @@ function kn(t) {
|
|
|
5212
5212
|
});
|
|
5213
5213
|
}
|
|
5214
5214
|
function Cn() {
|
|
5215
|
-
const { t } =
|
|
5215
|
+
const { t } = X(), { sessionId: n } = pt(), a = Oe(), s = mt(), [o] = kt(), i = o.get("demo") === "1", [c, l] = N(""), [g, d] = N(""), [p, m] = N([]), [x, C] = N(""), [b, f] = N(!1), _ = H(null), {
|
|
5216
5216
|
connectionStatus: A,
|
|
5217
5217
|
connectionVersion: q,
|
|
5218
5218
|
createSession: u,
|
|
5219
|
-
startDemo:
|
|
5219
|
+
startDemo: h,
|
|
5220
5220
|
completeDemoTyping: D,
|
|
5221
|
-
loadHistory:
|
|
5221
|
+
loadHistory: k,
|
|
5222
5222
|
loadMoreHistory: w,
|
|
5223
5223
|
sendMessage: W,
|
|
5224
|
-
getMessages:
|
|
5224
|
+
getMessages: v,
|
|
5225
5225
|
hasMoreHistory: I,
|
|
5226
5226
|
isLoadingOlder: z,
|
|
5227
5227
|
isThinking: V,
|
|
5228
|
-
getDemoStatus:
|
|
5228
|
+
getDemoStatus: ee,
|
|
5229
5229
|
getDemoTypingCue: de
|
|
5230
|
-
} = tt(), R = H(null), K = H(null), ie = H(null), le = H(null), [ge, T] = N(0), Q = H(!1), ce = H(null), ae = H(0), Be = H(!0), Ae = H(null), _e = H(!1), Ue = H(null), Re =
|
|
5230
|
+
} = tt(), R = H(null), K = H(null), ie = H(null), le = H(null), [ge, T] = N(0), Q = H(!1), ce = H(null), ae = H(0), Be = H(!0), Ae = H(null), _e = H(!1), Ue = H(null), Re = v(n), he = A === "connected", xe = V(n), qe = ee(n), Fe = de(n), Pe = i || qe === "running", nt = I(n), Je = z(n), at = Re[Re.length - 1], _t = at ? `${at.type}:${at.timestamp || ""}:${at.content}` : "empty", Ye = ke(() => {
|
|
5231
5231
|
_e.current = !0, Ue.current !== null && window.clearTimeout(Ue.current), Ue.current = window.setTimeout(() => {
|
|
5232
5232
|
_e.current = !1, Ue.current = null;
|
|
5233
5233
|
}, 600);
|
|
@@ -5274,14 +5274,14 @@ function Cn() {
|
|
|
5274
5274
|
Ae.current = y ? y.scrollHeight : null, Be.current = !1, w(n).catch(() => {
|
|
5275
5275
|
Ae.current = null;
|
|
5276
5276
|
});
|
|
5277
|
-
}, [n, Je, nt, w]),
|
|
5277
|
+
}, [n, Je, nt, w]), S = H(null);
|
|
5278
5278
|
se(() => {
|
|
5279
5279
|
d(""), ce.current = null, ae.current += 1, n && Wn(n);
|
|
5280
5280
|
const y = s.state;
|
|
5281
|
-
y != null && y.prefillMessage &&
|
|
5281
|
+
y != null && y.prefillMessage && S.current !== y ? (S.current = y, l(y.prefillMessage), window.setTimeout(() => {
|
|
5282
5282
|
var P;
|
|
5283
5283
|
return (P = ie.current) == null ? void 0 : P.focus();
|
|
5284
|
-
}, 50)) : y != null && y.prefillMessage || (
|
|
5284
|
+
}, 50)) : y != null && y.prefillMessage || (S.current = null, l(""));
|
|
5285
5285
|
}, [n, i, s.state]), se(() => {
|
|
5286
5286
|
if (n || !he) return;
|
|
5287
5287
|
let y = !1;
|
|
@@ -5292,10 +5292,10 @@ function Cn() {
|
|
|
5292
5292
|
y = !0;
|
|
5293
5293
|
};
|
|
5294
5294
|
}, [n, he, a]);
|
|
5295
|
-
const j = H(
|
|
5295
|
+
const j = H(k);
|
|
5296
5296
|
se(() => {
|
|
5297
|
-
j.current =
|
|
5298
|
-
}, [
|
|
5297
|
+
j.current = k;
|
|
5298
|
+
}, [k]), se(() => {
|
|
5299
5299
|
!n || !he || i || qe === "running" || j.current(n).catch(() => {
|
|
5300
5300
|
});
|
|
5301
5301
|
}, [n, he, q, i, qe]), se(() => {
|
|
@@ -5310,10 +5310,10 @@ function Cn() {
|
|
|
5310
5310
|
Be.current = te < 80;
|
|
5311
5311
|
}
|
|
5312
5312
|
se(() => {
|
|
5313
|
-
!n || !he || !i || ce.current !== n && (ce.current = n, d(""),
|
|
5313
|
+
!n || !he || !i || ce.current !== n && (ce.current = n, d(""), h(n).catch((y) => {
|
|
5314
5314
|
ce.current = null, d(y instanceof Error ? y.message : t("chat.demoError"));
|
|
5315
5315
|
}));
|
|
5316
|
-
}, [n, he, i,
|
|
5316
|
+
}, [n, he, i, h]), se(() => {
|
|
5317
5317
|
!n || !i || qe !== "complete" || (l(""), a(`/chat/${n}`, { replace: !0 }));
|
|
5318
5318
|
}, [n, i, qe, a]);
|
|
5319
5319
|
const we = H(D);
|
|
@@ -5339,34 +5339,34 @@ function Cn() {
|
|
|
5339
5339
|
}, [qe]);
|
|
5340
5340
|
const ve = ke((y) => {
|
|
5341
5341
|
if (!n) return;
|
|
5342
|
-
|
|
5342
|
+
C("");
|
|
5343
5343
|
const P = Array.from(y);
|
|
5344
|
-
|
|
5344
|
+
m((te) => {
|
|
5345
5345
|
const re = [...te];
|
|
5346
5346
|
for (const ne of P) {
|
|
5347
5347
|
if (re.length >= zt) {
|
|
5348
|
-
|
|
5348
|
+
C(`Maximum ${zt} attachments per message.`);
|
|
5349
5349
|
break;
|
|
5350
5350
|
}
|
|
5351
5351
|
if (!os.has(ne.type)) {
|
|
5352
|
-
|
|
5352
|
+
C(`Unsupported file type: ${ne.type || ne.name}`);
|
|
5353
5353
|
continue;
|
|
5354
5354
|
}
|
|
5355
5355
|
if (ne.size > is) {
|
|
5356
|
-
|
|
5356
|
+
C(`"${ne.name}" is too large (max 10 MB).`);
|
|
5357
5357
|
continue;
|
|
5358
5358
|
}
|
|
5359
5359
|
const rt = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Tt = ne.type.startsWith("image/") ? URL.createObjectURL(ne) : void 0, At = { localId: rt, file: ne, previewUrl: Tt, uploading: !0 };
|
|
5360
|
-
re.push(At), O.uploadChatAttachment(n, ne).then((
|
|
5361
|
-
|
|
5360
|
+
re.push(At), O.uploadChatAttachment(n, ne).then((ot) => {
|
|
5361
|
+
m(
|
|
5362
5362
|
(gt) => gt.map(
|
|
5363
|
-
(
|
|
5363
|
+
(lt) => lt.localId === rt ? { ...lt, uploading: !1, uploadedId: ot.id } : lt
|
|
5364
5364
|
)
|
|
5365
5365
|
);
|
|
5366
|
-
}).catch((
|
|
5367
|
-
const gt = (
|
|
5368
|
-
|
|
5369
|
-
(
|
|
5366
|
+
}).catch((ot) => {
|
|
5367
|
+
const gt = (ot == null ? void 0 : ot.message) || "Upload failed";
|
|
5368
|
+
C(`"${ne.name}": ${gt}`), m(
|
|
5369
|
+
(lt) => lt.map(
|
|
5370
5370
|
(Rt) => Rt.localId === rt ? { ...Rt, uploading: !1, error: gt } : Rt
|
|
5371
5371
|
)
|
|
5372
5372
|
);
|
|
@@ -5375,7 +5375,7 @@ function Cn() {
|
|
|
5375
5375
|
return re;
|
|
5376
5376
|
});
|
|
5377
5377
|
}, [n]), Ze = (y) => {
|
|
5378
|
-
|
|
5378
|
+
m((P) => {
|
|
5379
5379
|
const te = P.find((re) => re.localId === y);
|
|
5380
5380
|
return te != null && te.previewUrl && URL.revokeObjectURL(te.previewUrl), P.filter((re) => re.localId !== y);
|
|
5381
5381
|
});
|
|
@@ -5394,13 +5394,13 @@ function Cn() {
|
|
|
5394
5394
|
re && P.push(re);
|
|
5395
5395
|
}
|
|
5396
5396
|
P.length > 0 && (y.preventDefault(), ve(P));
|
|
5397
|
-
}, B =
|
|
5397
|
+
}, B = p.some((y) => y.uploading), M = p.some((y) => y.error), U = p.filter((y) => y.uploadedId && !y.error).map((y) => y.uploadedId);
|
|
5398
5398
|
function Te() {
|
|
5399
5399
|
const y = c.trim();
|
|
5400
5400
|
if (n && !(!y && U.length === 0) && !B && W(n, y, U.length > 0 ? U : void 0)) {
|
|
5401
|
-
for (const P of
|
|
5401
|
+
for (const P of p)
|
|
5402
5402
|
P.previewUrl && URL.revokeObjectURL(P.previewUrl);
|
|
5403
|
-
|
|
5403
|
+
m([]), C(""), l("");
|
|
5404
5404
|
}
|
|
5405
5405
|
}
|
|
5406
5406
|
function be(y) {
|
|
@@ -5414,7 +5414,7 @@ function Cn() {
|
|
|
5414
5414
|
onDragLeave: Xe,
|
|
5415
5415
|
onDrop: me,
|
|
5416
5416
|
children: [
|
|
5417
|
-
|
|
5417
|
+
b && /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-3 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-brand bg-brand/5 text-sm font-medium text-brand", children: t("chat.dropToAttach") }),
|
|
5418
5418
|
/* @__PURE__ */ e(
|
|
5419
5419
|
"div",
|
|
5420
5420
|
{
|
|
@@ -5436,7 +5436,7 @@ function Cn() {
|
|
|
5436
5436
|
children: t(Je ? "common.loading" : "chat.loadOlder")
|
|
5437
5437
|
}
|
|
5438
5438
|
) }),
|
|
5439
|
-
|
|
5439
|
+
g && /* @__PURE__ */ e("div", { className: "rounded-md bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: g }),
|
|
5440
5440
|
Re.length === 0 && qe !== "running" && !i && /* @__PURE__ */ r("div", { className: "py-20 text-center", children: [
|
|
5441
5441
|
/* @__PURE__ */ e("h3", { className: "text-lg font-semibold text-fg-muted", children: t("chat.title") }),
|
|
5442
5442
|
/* @__PURE__ */ e("p", { className: "mt-2 text-sm text-fg-muted", children: t("chat.subtitle") }),
|
|
@@ -5471,7 +5471,7 @@ function Cn() {
|
|
|
5471
5471
|
ref: le,
|
|
5472
5472
|
className: "absolute bottom-0 left-0 right-0 bg-surface-muted px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:right-6 md:pl-6 md:pr-0",
|
|
5473
5473
|
children: /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl", children: [
|
|
5474
|
-
|
|
5474
|
+
p.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 flex flex-wrap gap-2", children: p.map((y) => /* @__PURE__ */ r(
|
|
5475
5475
|
"div",
|
|
5476
5476
|
{
|
|
5477
5477
|
className: "relative flex items-center gap-2 rounded-lg bg-surface px-2 py-1.5 text-xs ring-1 ring-line shadow-card",
|
|
@@ -5535,7 +5535,7 @@ function Cn() {
|
|
|
5535
5535
|
var y;
|
|
5536
5536
|
return (y = _.current) == null ? void 0 : y.click();
|
|
5537
5537
|
},
|
|
5538
|
-
disabled: !he || !n || xe || Pe ||
|
|
5538
|
+
disabled: !he || !n || xe || Pe || p.length >= zt,
|
|
5539
5539
|
className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-all hover:bg-surface-subtle hover:text-fg disabled:cursor-not-allowed disabled:opacity-40 md:h-10 md:w-10",
|
|
5540
5540
|
title: t("chat.attachTitle"),
|
|
5541
5541
|
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48" }) })
|
|
@@ -5725,24 +5725,24 @@ function ps(t, n) {
|
|
|
5725
5725
|
let c = 0;
|
|
5726
5726
|
for (; (o = i.exec(t)) !== null; ) {
|
|
5727
5727
|
const l = o.index;
|
|
5728
|
-
let
|
|
5729
|
-
for (;
|
|
5730
|
-
d =
|
|
5731
|
-
l > s && a.push(t.slice(s, l)), a.push(Xn(
|
|
5728
|
+
let g = o[0], d = "";
|
|
5729
|
+
for (; g.length > 0 && /[.,;:!?]$/.test(g); )
|
|
5730
|
+
d = g.slice(-1) + d, g = g.slice(0, -1);
|
|
5731
|
+
l > s && a.push(t.slice(s, l)), a.push(Xn(g, g, `${n}-u${c}`)), d && a.push(d), s = l + o[0].length, c += 1;
|
|
5732
5732
|
}
|
|
5733
5733
|
return s < t.length && a.push(t.slice(s)), a.length > 0 ? a : [t];
|
|
5734
5734
|
}
|
|
5735
5735
|
function hs() {
|
|
5736
|
-
const t = Oe(), [n] = kt(), { user: a, login: s, register: o } =
|
|
5736
|
+
const t = Oe(), [n] = kt(), { user: a, login: s, register: o } = it(), { t: i } = X(), c = n.get("invite") || "", [l, g] = N(c ? "register" : "login"), [d, p] = N(!1), [m, x] = N(!1), [C, b] = N(!0), [f, _] = N(""), [A, q] = N(""), [u, h] = N(""), [D, k] = N(""), [w, W] = N("");
|
|
5737
5737
|
se(() => {
|
|
5738
5738
|
a && a.role !== "public_manager" && t("/", { replace: !0 });
|
|
5739
5739
|
}, [a, t]), se(() => {
|
|
5740
5740
|
O.authSetupStatus().then((I) => {
|
|
5741
|
-
|
|
5741
|
+
p(I.registration_open), x(I.first_run), I.first_run && g("register");
|
|
5742
5742
|
}).catch(() => {
|
|
5743
|
-
}).finally(() =>
|
|
5743
|
+
}).finally(() => b(!1));
|
|
5744
5744
|
}, []);
|
|
5745
|
-
const
|
|
5745
|
+
const v = async (I) => {
|
|
5746
5746
|
if (I.preventDefault(), _(""), l === "register") {
|
|
5747
5747
|
if (D !== w) {
|
|
5748
5748
|
_(i("login.passwordsNoMatch"));
|
|
@@ -5764,20 +5764,20 @@ function hs() {
|
|
|
5764
5764
|
_(z instanceof Ke ? z.message : i("login.loginFailed"));
|
|
5765
5765
|
}
|
|
5766
5766
|
};
|
|
5767
|
-
return
|
|
5767
|
+
return C ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center bg-surface-muted", children: /* @__PURE__ */ e("div", { className: "text-fg-muted", children: i("common.loading") }) }) : /* @__PURE__ */ e("div", { className: "flex min-h-dvh items-center justify-center bg-surface-muted px-4", children: /* @__PURE__ */ r("div", { className: "w-full max-w-sm space-y-6", children: [
|
|
5768
5768
|
/* @__PURE__ */ r("div", { className: "text-center", children: [
|
|
5769
5769
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-brand", children: "Lambda ERP" }),
|
|
5770
|
-
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: i(
|
|
5770
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: i(m ? "login.taglineFirstRun" : l === "register" ? "login.taglineRegister" : "login.taglineSignIn") }),
|
|
5771
5771
|
(a == null ? void 0 : a.role) === "public_manager" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-amber-700", children: i("login.demoBanner") })
|
|
5772
5772
|
] }),
|
|
5773
5773
|
f && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: f }),
|
|
5774
|
-
/* @__PURE__ */ e($, { children: /* @__PURE__ */ r("form", { onSubmit:
|
|
5774
|
+
/* @__PURE__ */ e($, { children: /* @__PURE__ */ r("form", { onSubmit: v, className: "space-y-4", children: [
|
|
5775
5775
|
l === "register" && /* @__PURE__ */ e(
|
|
5776
5776
|
Y,
|
|
5777
5777
|
{
|
|
5778
5778
|
label: i("login.fullName"),
|
|
5779
5779
|
value: u,
|
|
5780
|
-
onChange: (I) =>
|
|
5780
|
+
onChange: (I) => h(I.target.value),
|
|
5781
5781
|
required: !0
|
|
5782
5782
|
}
|
|
5783
5783
|
),
|
|
@@ -5797,7 +5797,7 @@ function hs() {
|
|
|
5797
5797
|
label: i("login.password"),
|
|
5798
5798
|
type: "password",
|
|
5799
5799
|
value: D,
|
|
5800
|
-
onChange: (I) =>
|
|
5800
|
+
onChange: (I) => k(I.target.value),
|
|
5801
5801
|
required: !0
|
|
5802
5802
|
}
|
|
5803
5803
|
),
|
|
@@ -5811,7 +5811,7 @@ function hs() {
|
|
|
5811
5811
|
required: !0
|
|
5812
5812
|
}
|
|
5813
5813
|
),
|
|
5814
|
-
/* @__PURE__ */ e(
|
|
5814
|
+
/* @__PURE__ */ e(Z, { type: "submit", className: "w-full", children: i(l === "register" ? m ? "login.createAdmin" : "login.register" : "login.signIn") })
|
|
5815
5815
|
] }) }),
|
|
5816
5816
|
(a == null ? void 0 : a.role) === "public_manager" && /* @__PURE__ */ e($, { children: /* @__PURE__ */ r("div", { className: "space-y-3", children: [
|
|
5817
5817
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -5819,7 +5819,7 @@ function hs() {
|
|
|
5819
5819
|
/* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: i("login.browsingBody") })
|
|
5820
5820
|
] }),
|
|
5821
5821
|
/* @__PURE__ */ e(
|
|
5822
|
-
|
|
5822
|
+
Z,
|
|
5823
5823
|
{
|
|
5824
5824
|
type: "button",
|
|
5825
5825
|
className: "w-full",
|
|
@@ -5828,14 +5828,14 @@ function hs() {
|
|
|
5828
5828
|
}
|
|
5829
5829
|
)
|
|
5830
5830
|
] }) }),
|
|
5831
|
-
!
|
|
5831
|
+
!m && !c && /* @__PURE__ */ e("p", { className: "text-center text-sm text-fg-muted", children: l === "login" ? /* @__PURE__ */ r(Ne, { children: [
|
|
5832
5832
|
i(d ? "login.noAccountPrompt" : "login.haveInvite"),
|
|
5833
5833
|
" ",
|
|
5834
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
5834
|
+
/* @__PURE__ */ e("button", { onClick: () => g("register"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.registerLink") })
|
|
5835
5835
|
] }) : /* @__PURE__ */ r(Ne, { children: [
|
|
5836
5836
|
i("login.alreadyHaveAccount"),
|
|
5837
5837
|
" ",
|
|
5838
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
5838
|
+
/* @__PURE__ */ e("button", { onClick: () => g("login"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.signInLink") })
|
|
5839
5839
|
] }) })
|
|
5840
5840
|
] }) });
|
|
5841
5841
|
}
|
|
@@ -5872,54 +5872,54 @@ function Pn() {
|
|
|
5872
5872
|
return { type: "sales", party: "", amount: "", due_date: "", remarks: "" };
|
|
5873
5873
|
}
|
|
5874
5874
|
function ys() {
|
|
5875
|
-
const t = Oe(), n = Qe(), [a, s] = N(""), [o, i] = N((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = N(""), [
|
|
5875
|
+
const t = Oe(), n = Qe(), [a, s] = N(""), [o, i] = N((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = N(""), [g, d] = N([Dn()]), [p, m] = N([_n()]), [x, C] = N([Pn()]), [b, f] = N({}), _ = ue({
|
|
5876
5876
|
mutationFn: () => O.importAccountBalances({
|
|
5877
5877
|
company: a,
|
|
5878
5878
|
posting_date: o,
|
|
5879
|
-
entries:
|
|
5880
|
-
account:
|
|
5881
|
-
debit: parseFloat(
|
|
5882
|
-
credit: parseFloat(
|
|
5883
|
-
party_type:
|
|
5884
|
-
party:
|
|
5879
|
+
entries: g.filter((h) => h.account && (h.debit || h.credit)).map((h) => ({
|
|
5880
|
+
account: h.account,
|
|
5881
|
+
debit: parseFloat(h.debit) || 0,
|
|
5882
|
+
credit: parseFloat(h.credit) || 0,
|
|
5883
|
+
party_type: h.party_type || void 0,
|
|
5884
|
+
party: h.party || void 0
|
|
5885
5885
|
}))
|
|
5886
5886
|
}),
|
|
5887
|
-
onSuccess: (
|
|
5887
|
+
onSuccess: (h) => f((D) => ({ ...D, accounts: h }))
|
|
5888
5888
|
}), A = ue({
|
|
5889
5889
|
mutationFn: () => O.importStockBalances({
|
|
5890
5890
|
company: a,
|
|
5891
5891
|
posting_date: o,
|
|
5892
5892
|
warehouse: c,
|
|
5893
|
-
items:
|
|
5894
|
-
item_code:
|
|
5895
|
-
qty: parseFloat(
|
|
5896
|
-
rate: parseFloat(
|
|
5893
|
+
items: p.filter((h) => h.item_code && h.qty).map((h) => ({
|
|
5894
|
+
item_code: h.item_code,
|
|
5895
|
+
qty: parseFloat(h.qty) || 0,
|
|
5896
|
+
rate: parseFloat(h.rate) || 0
|
|
5897
5897
|
}))
|
|
5898
5898
|
}),
|
|
5899
|
-
onSuccess: (
|
|
5899
|
+
onSuccess: (h) => f((D) => ({ ...D, stock: h }))
|
|
5900
5900
|
}), q = ue({
|
|
5901
5901
|
mutationFn: () => O.importOutstandingInvoices({
|
|
5902
5902
|
company: a,
|
|
5903
|
-
invoices: x.filter((
|
|
5904
|
-
type:
|
|
5905
|
-
party:
|
|
5906
|
-
amount: parseFloat(
|
|
5907
|
-
due_date:
|
|
5908
|
-
remarks:
|
|
5903
|
+
invoices: x.filter((h) => h.party && h.amount).map((h) => ({
|
|
5904
|
+
type: h.type,
|
|
5905
|
+
party: h.party,
|
|
5906
|
+
amount: parseFloat(h.amount) || 0,
|
|
5907
|
+
due_date: h.due_date || void 0,
|
|
5908
|
+
remarks: h.remarks || void 0,
|
|
5909
5909
|
posting_date: o
|
|
5910
5910
|
}))
|
|
5911
5911
|
}),
|
|
5912
|
-
onSuccess: (
|
|
5912
|
+
onSuccess: (h) => f((D) => ({ ...D, invoices: h }))
|
|
5913
5913
|
});
|
|
5914
|
-
function u(
|
|
5915
|
-
const
|
|
5916
|
-
|
|
5914
|
+
function u(h, D, k, w, W) {
|
|
5915
|
+
const v = [...h];
|
|
5916
|
+
v[k][w] = W, D(v);
|
|
5917
5917
|
}
|
|
5918
5918
|
return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
|
|
5919
5919
|
/* @__PURE__ */ e("p", { className: "text-sm text-gray-500", children: "Import balances from your previous system. Each section creates the appropriate documents (Journal Entry, Stock Entry, or Invoices) and submits them automatically." }),
|
|
5920
5920
|
/* @__PURE__ */ e($, { title: "Common Settings", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
|
|
5921
5921
|
/* @__PURE__ */ e(Se, { label: "Company", value: a, onChange: s, linkDoctype: "company", readOnly: !1 }),
|
|
5922
|
-
/* @__PURE__ */ e(Y, { label: "As-of Date", type: "date", value: o, onChange: (
|
|
5922
|
+
/* @__PURE__ */ e(Y, { label: "As-of Date", type: "date", value: o, onChange: (h) => i(h.target.value) })
|
|
5923
5923
|
] }) }),
|
|
5924
5924
|
/* @__PURE__ */ r($, { title: "1. Account Balances", children: [
|
|
5925
5925
|
/* @__PURE__ */ e("p", { className: "mb-3 text-xs text-gray-500", children: "Enter your trial balance from the old system. The difference will be automatically balanced against Opening Balance Equity. For receivable/payable accounts, also set the party type and party." }),
|
|
@@ -5931,25 +5931,25 @@ function ys() {
|
|
|
5931
5931
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Debit" }),
|
|
5932
5932
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Credit" })
|
|
5933
5933
|
] }) }),
|
|
5934
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
5935
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { value:
|
|
5936
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value:
|
|
5934
|
+
/* @__PURE__ */ e("tbody", { children: g.map((h, D) => /* @__PURE__ */ r("tr", { children: [
|
|
5935
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { value: h.account, onChange: (k) => u(g, d, D, "account", k), linkDoctype: "account", readOnly: !1, label: "" }) }),
|
|
5936
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.party_type, onChange: (k) => u(g, d, D, "party_type", k.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
|
|
5937
5937
|
/* @__PURE__ */ e("option", { value: "", children: "—" }),
|
|
5938
5938
|
/* @__PURE__ */ e("option", { value: "Customer", children: "Customer" }),
|
|
5939
5939
|
/* @__PURE__ */ e("option", { value: "Supplier", children: "Supplier" })
|
|
5940
5940
|
] }) }),
|
|
5941
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children:
|
|
5942
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value:
|
|
5943
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value:
|
|
5941
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: h.party_type ? /* @__PURE__ */ e(Se, { label: "", value: h.party, onChange: (k) => u(g, d, D, "party", k), linkDoctype: h.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ e("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
|
|
5942
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.debit, onChange: (k) => u(g, d, D, "debit", k.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
|
|
5943
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.credit, onChange: (k) => u(g, d, D, "credit", k.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
|
|
5944
5944
|
] }, D)) })
|
|
5945
5945
|
] }) }),
|
|
5946
|
-
/* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => d([...
|
|
5946
|
+
/* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => d([...g, Dn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
|
|
5947
5947
|
/* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
|
|
5948
|
-
/* @__PURE__ */ e(
|
|
5948
|
+
/* @__PURE__ */ e(Z, { onClick: () => _.mutate(), disabled: !a || _.isPending, children: _.isPending ? "Importing..." : "Import Account Balances" }),
|
|
5949
5949
|
_.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: _.error.message }),
|
|
5950
|
-
|
|
5950
|
+
b.accounts && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
|
|
5951
5951
|
"Created ",
|
|
5952
|
-
|
|
5952
|
+
b.accounts.journal_entry
|
|
5953
5953
|
] })
|
|
5954
5954
|
] })
|
|
5955
5955
|
] }),
|
|
@@ -5962,21 +5962,21 @@ function ys() {
|
|
|
5962
5962
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Qty" }),
|
|
5963
5963
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Rate" })
|
|
5964
5964
|
] }) }),
|
|
5965
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
5966
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { label: "", value:
|
|
5967
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value:
|
|
5968
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value:
|
|
5965
|
+
/* @__PURE__ */ e("tbody", { children: p.map((h, D) => /* @__PURE__ */ r("tr", { children: [
|
|
5966
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { label: "", value: h.item_code, onChange: (k) => u(p, m, D, "item_code", k), linkDoctype: "item", readOnly: !1 }) }),
|
|
5967
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.qty, onChange: (k) => u(p, m, D, "qty", k.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0" }) }),
|
|
5968
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.rate, onChange: (k) => u(p, m, D, "rate", k.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
|
|
5969
5969
|
] }, D)) })
|
|
5970
5970
|
] }) }),
|
|
5971
|
-
/* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () =>
|
|
5971
|
+
/* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => m([...p, _n()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
|
|
5972
5972
|
/* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
|
|
5973
|
-
/* @__PURE__ */ e(
|
|
5973
|
+
/* @__PURE__ */ e(Z, { onClick: () => A.mutate(), disabled: !a || !c || A.isPending, children: A.isPending ? "Importing..." : "Import Stock Balances" }),
|
|
5974
5974
|
A.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: A.error.message }),
|
|
5975
|
-
|
|
5975
|
+
b.stock && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
|
|
5976
5976
|
"Created ",
|
|
5977
|
-
|
|
5977
|
+
b.stock.stock_entry,
|
|
5978
5978
|
" (",
|
|
5979
|
-
|
|
5979
|
+
b.stock.items_count,
|
|
5980
5980
|
" items)"
|
|
5981
5981
|
] })
|
|
5982
5982
|
] })
|
|
@@ -5991,8 +5991,8 @@ function ys() {
|
|
|
5991
5991
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Due Date" }),
|
|
5992
5992
|
/* @__PURE__ */ e("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Ref / Remarks" })
|
|
5993
5993
|
] }) }),
|
|
5994
|
-
/* @__PURE__ */ e("tbody", { children: x.map((
|
|
5995
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value:
|
|
5994
|
+
/* @__PURE__ */ e("tbody", { children: x.map((h, D) => /* @__PURE__ */ r("tr", { children: [
|
|
5995
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.type, onChange: (k) => u(x, C, D, "type", k.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
|
|
5996
5996
|
/* @__PURE__ */ e("option", { value: "sales", children: "Sales (AR)" }),
|
|
5997
5997
|
/* @__PURE__ */ e("option", { value: "purchase", children: "Purchase (AP)" })
|
|
5998
5998
|
] }) }),
|
|
@@ -6000,24 +6000,24 @@ function ys() {
|
|
|
6000
6000
|
Se,
|
|
6001
6001
|
{
|
|
6002
6002
|
label: "",
|
|
6003
|
-
value:
|
|
6004
|
-
onChange: (
|
|
6005
|
-
linkDoctype:
|
|
6003
|
+
value: h.party,
|
|
6004
|
+
onChange: (k) => u(x, C, D, "party", k),
|
|
6005
|
+
linkDoctype: h.type === "sales" ? "customer" : "supplier",
|
|
6006
6006
|
readOnly: !1
|
|
6007
6007
|
}
|
|
6008
6008
|
) }),
|
|
6009
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value:
|
|
6010
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value:
|
|
6011
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value:
|
|
6009
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.amount, onChange: (k) => u(x, C, D, "amount", k.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
|
|
6010
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value: h.due_date, onChange: (k) => u(x, C, D, "due_date", k.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
|
|
6011
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value: h.remarks, onChange: (k) => u(x, C, D, "remarks", k.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
|
|
6012
6012
|
] }, D)) })
|
|
6013
6013
|
] }) }),
|
|
6014
|
-
/* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () =>
|
|
6014
|
+
/* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => C([...x, Pn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
|
|
6015
6015
|
/* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
|
|
6016
|
-
/* @__PURE__ */ e(
|
|
6016
|
+
/* @__PURE__ */ e(Z, { onClick: () => q.mutate(), disabled: !a || q.isPending, children: q.isPending ? "Importing..." : "Import Outstanding Invoices" }),
|
|
6017
6017
|
q.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: q.error.message }),
|
|
6018
|
-
|
|
6018
|
+
b.invoices && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
|
|
6019
6019
|
"Created ",
|
|
6020
|
-
|
|
6020
|
+
b.invoices.invoices_created,
|
|
6021
6021
|
" invoices"
|
|
6022
6022
|
] })
|
|
6023
6023
|
] })
|
|
@@ -6038,29 +6038,29 @@ function ys() {
|
|
|
6038
6038
|
] });
|
|
6039
6039
|
}
|
|
6040
6040
|
function fs() {
|
|
6041
|
-
const { user: t } =
|
|
6041
|
+
const { user: t } = it(), n = Qe(), { data: a, isLoading: s } = oe({
|
|
6042
6042
|
queryKey: ["auth-users"],
|
|
6043
6043
|
queryFn: () => O.authListUsers()
|
|
6044
6044
|
}), { data: o } = oe({
|
|
6045
6045
|
queryKey: ["auth-invites"],
|
|
6046
6046
|
queryFn: () => O.authListInvites()
|
|
6047
|
-
}), [i, c] = N(""), [l,
|
|
6047
|
+
}), [i, c] = N(""), [l, g] = N("viewer"), [d, p] = N(null), m = ue({
|
|
6048
6048
|
mutationFn: () => O.authInvite(i, l),
|
|
6049
6049
|
onSuccess: (u) => {
|
|
6050
|
-
|
|
6050
|
+
p(u), c(""), n.invalidateQueries({ queryKey: ["auth-invites"] });
|
|
6051
6051
|
}
|
|
6052
6052
|
}), x = ue({
|
|
6053
|
-
mutationFn: ({ name: u, role:
|
|
6053
|
+
mutationFn: ({ name: u, role: h }) => O.authChangeRole(u, h),
|
|
6054
6054
|
onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
|
|
6055
|
-
}),
|
|
6055
|
+
}), C = ue({
|
|
6056
6056
|
mutationFn: (u) => O.authDisableUser(u),
|
|
6057
6057
|
onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
|
|
6058
|
-
}),
|
|
6058
|
+
}), b = ue({
|
|
6059
6059
|
mutationFn: (u) => O.authRevokeInvite(u),
|
|
6060
6060
|
onSuccess: () => n.invalidateQueries({ queryKey: ["auth-invites"] })
|
|
6061
6061
|
}), [f, _] = N(null), A = (u) => `${window.location.origin}/login?invite=${u}`, q = async (u) => {
|
|
6062
6062
|
try {
|
|
6063
|
-
await navigator.clipboard.writeText(A(u)), _(u), setTimeout(() => _((
|
|
6063
|
+
await navigator.clipboard.writeText(A(u)), _(u), setTimeout(() => _((h) => h === u ? null : h), 2e3);
|
|
6064
6064
|
} catch {
|
|
6065
6065
|
window.prompt("Invite link", A(u));
|
|
6066
6066
|
}
|
|
@@ -6098,19 +6098,19 @@ function fs() {
|
|
|
6098
6098
|
label: "Role",
|
|
6099
6099
|
options: ["viewer", "manager", "admin"],
|
|
6100
6100
|
value: l,
|
|
6101
|
-
onChange: (u) =>
|
|
6101
|
+
onChange: (u) => g(u.target.value)
|
|
6102
6102
|
}
|
|
6103
6103
|
),
|
|
6104
6104
|
/* @__PURE__ */ e(
|
|
6105
|
-
|
|
6105
|
+
Z,
|
|
6106
6106
|
{
|
|
6107
|
-
onClick: () =>
|
|
6108
|
-
disabled: !i.trim() ||
|
|
6109
|
-
children:
|
|
6107
|
+
onClick: () => m.mutate(),
|
|
6108
|
+
disabled: !i.trim() || m.isPending,
|
|
6109
|
+
children: m.isPending ? "Sending..." : "Create Invite"
|
|
6110
6110
|
}
|
|
6111
6111
|
)
|
|
6112
6112
|
] }),
|
|
6113
|
-
|
|
6113
|
+
m.error && /* @__PURE__ */ e("p", { className: "mt-2 text-sm text-red-600", children: m.error.message }),
|
|
6114
6114
|
d && /* @__PURE__ */ r("div", { className: "mt-3 rounded-md bg-green-50 px-4 py-3 text-sm", children: [
|
|
6115
6115
|
/* @__PURE__ */ e("p", { className: "font-medium text-green-800", children: "Invite created!" }),
|
|
6116
6116
|
/* @__PURE__ */ r("p", { className: "mt-1 text-green-700", children: [
|
|
@@ -6131,26 +6131,28 @@ function fs() {
|
|
|
6131
6131
|
/* @__PURE__ */ e("th", { className: "px-4 py-2 text-right font-medium text-gray-500", children: "Actions" })
|
|
6132
6132
|
] }) }),
|
|
6133
6133
|
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: o.filter((u) => !u.used).map((u) => {
|
|
6134
|
-
var
|
|
6134
|
+
var h;
|
|
6135
6135
|
return /* @__PURE__ */ r("tr", { children: [
|
|
6136
6136
|
/* @__PURE__ */ e("td", { className: "px-4 py-2", children: u.email }),
|
|
6137
6137
|
/* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e("span", { className: "rounded bg-gray-100 px-2 py-0.5 text-xs font-medium", children: u.role }) }),
|
|
6138
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: (
|
|
6139
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-
|
|
6138
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: (h = u.creation) == null ? void 0 : h.split("T")[0] }),
|
|
6139
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
|
|
6140
6140
|
/* @__PURE__ */ e(
|
|
6141
|
-
|
|
6141
|
+
Z,
|
|
6142
6142
|
{
|
|
6143
|
+
variant: "secondary",
|
|
6144
|
+
size: "sm",
|
|
6143
6145
|
onClick: () => q(u.token),
|
|
6144
|
-
className: "text-xs font-medium text-brand hover:text-brand/80",
|
|
6145
6146
|
children: f === u.token ? "Copied!" : "Copy link"
|
|
6146
6147
|
}
|
|
6147
6148
|
),
|
|
6148
6149
|
/* @__PURE__ */ e(
|
|
6149
|
-
|
|
6150
|
+
Z,
|
|
6150
6151
|
{
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6152
|
+
variant: "danger",
|
|
6153
|
+
size: "sm",
|
|
6154
|
+
onClick: () => b.mutate(u.token),
|
|
6155
|
+
disabled: b.isPending,
|
|
6154
6156
|
children: "Revoke"
|
|
6155
6157
|
}
|
|
6156
6158
|
)
|
|
@@ -6173,7 +6175,7 @@ function fs() {
|
|
|
6173
6175
|
"select",
|
|
6174
6176
|
{
|
|
6175
6177
|
value: u.role,
|
|
6176
|
-
onChange: (
|
|
6178
|
+
onChange: (h) => x.mutate({ name: u.name, role: h.target.value }),
|
|
6177
6179
|
disabled: u.name === (t == null ? void 0 : t.name),
|
|
6178
6180
|
className: `rounded border px-2 py-1 text-xs ${u.name === (t == null ? void 0 : t.name) ? "border-gray-200 bg-gray-50 text-gray-400" : "border-gray-300 bg-white text-gray-900"}`,
|
|
6179
6181
|
children: [
|
|
@@ -6187,7 +6189,7 @@ function fs() {
|
|
|
6187
6189
|
/* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: u.name !== (t == null ? void 0 : t.name) && u.enabled ? /* @__PURE__ */ e(
|
|
6188
6190
|
"button",
|
|
6189
6191
|
{
|
|
6190
|
-
onClick: () =>
|
|
6192
|
+
onClick: () => C.mutate(u.name),
|
|
6191
6193
|
className: "text-xs text-red-500 hover:text-red-700",
|
|
6192
6194
|
children: "Disable"
|
|
6193
6195
|
}
|
|
@@ -6292,7 +6294,7 @@ $n.use(pa).init({
|
|
|
6292
6294
|
$n.on("languageChanged", Si);
|
|
6293
6295
|
function ki({ label: t }) {
|
|
6294
6296
|
var o;
|
|
6295
|
-
const { t: n, i18n: a } =
|
|
6297
|
+
const { t: n, i18n: a } = X(), s = ((o = a.language) == null ? void 0 : o.split("-")[0]) ?? "en";
|
|
6296
6298
|
return /* @__PURE__ */ e(
|
|
6297
6299
|
He,
|
|
6298
6300
|
{
|
|
@@ -6316,12 +6318,12 @@ function ze(t) {
|
|
|
6316
6318
|
}
|
|
6317
6319
|
function Ci({ demoActive: t }) {
|
|
6318
6320
|
var A, q;
|
|
6319
|
-
const { t: n } =
|
|
6321
|
+
const { t: n } = X(), [a, s] = N("1h"), { data: o, isLoading: i, isFetching: c, error: l, refetch: g, dataUpdatedAt: d } = oe({
|
|
6320
6322
|
queryKey: ["demo-spend"],
|
|
6321
6323
|
queryFn: () => O.getDemoSpend(),
|
|
6322
6324
|
// Refresh once a minute — demo spend changes slowly; no need to poll harder.
|
|
6323
6325
|
refetchInterval: 6e4
|
|
6324
|
-
}),
|
|
6326
|
+
}), p = Tn.find((u) => u.value === a), m = (A = o == null ? void 0 : o.windows) == null ? void 0 : A[a], x = ((q = o == null ? void 0 : o.caps) == null ? void 0 : q.global_hourly_usd) ?? 0, C = m ? m.demo_usd / p.hours : 0, b = m ? m.total_usd / p.hours : 0, f = x > 0 ? Math.min(100, C / x * 100) : 0, _ = f >= 90 ? "bg-red-500" : f >= 60 ? "bg-amber-500" : "bg-emerald-500";
|
|
6325
6327
|
return /* @__PURE__ */ r($, { title: n("settings.tokenSpendTitle"), children: [
|
|
6326
6328
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-4", children: [
|
|
6327
6329
|
/* @__PURE__ */ r("div", { className: "max-w-lg text-sm text-gray-600", children: [
|
|
@@ -6349,7 +6351,7 @@ function Ci({ demoActive: t }) {
|
|
|
6349
6351
|
"button",
|
|
6350
6352
|
{
|
|
6351
6353
|
type: "button",
|
|
6352
|
-
onClick: () =>
|
|
6354
|
+
onClick: () => g(),
|
|
6353
6355
|
disabled: c,
|
|
6354
6356
|
title: d ? `Last updated ${new Date(d).toLocaleTimeString()}` : "Refresh now",
|
|
6355
6357
|
className: "inline-flex h-[38px] items-center gap-1.5 rounded-md border border-gray-300 bg-white px-3 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60",
|
|
@@ -6382,7 +6384,7 @@ function Ci({ demoActive: t }) {
|
|
|
6382
6384
|
"Failed to load spend data: ",
|
|
6383
6385
|
l.message
|
|
6384
6386
|
] }),
|
|
6385
|
-
|
|
6387
|
+
m && /* @__PURE__ */ r("div", { className: "mt-5 space-y-5", children: [
|
|
6386
6388
|
t ? (
|
|
6387
6389
|
/* Demo deployments: spend-against-cap is the number that matters. */
|
|
6388
6390
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -6390,11 +6392,11 @@ function Ci({ demoActive: t }) {
|
|
|
6390
6392
|
/* @__PURE__ */ r("div", { children: [
|
|
6391
6393
|
/* @__PURE__ */ r("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: [
|
|
6392
6394
|
"Demo spend (avg/hr over ",
|
|
6393
|
-
|
|
6395
|
+
p.label.toLowerCase(),
|
|
6394
6396
|
")"
|
|
6395
6397
|
] }),
|
|
6396
6398
|
/* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
|
|
6397
|
-
ze(
|
|
6399
|
+
ze(C),
|
|
6398
6400
|
/* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
|
|
6399
6401
|
"/ ",
|
|
6400
6402
|
ze(x),
|
|
@@ -6405,10 +6407,10 @@ function Ci({ demoActive: t }) {
|
|
|
6405
6407
|
/* @__PURE__ */ r("div", { className: "text-right", children: [
|
|
6406
6408
|
/* @__PURE__ */ e("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: "Total (all roles)" }),
|
|
6407
6409
|
/* @__PURE__ */ r("div", { className: "mt-1 text-lg font-semibold text-gray-700", children: [
|
|
6408
|
-
ze(
|
|
6410
|
+
ze(m.total_usd),
|
|
6409
6411
|
/* @__PURE__ */ r("span", { className: "ml-1 text-xs font-normal text-gray-500", children: [
|
|
6410
6412
|
"(",
|
|
6411
|
-
ze(
|
|
6413
|
+
ze(b),
|
|
6412
6414
|
"/hr)"
|
|
6413
6415
|
] })
|
|
6414
6416
|
] })
|
|
@@ -6426,34 +6428,34 @@ function Ci({ demoActive: t }) {
|
|
|
6426
6428
|
/* @__PURE__ */ r("div", { children: [
|
|
6427
6429
|
/* @__PURE__ */ r("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: [
|
|
6428
6430
|
"Total spend (avg/hr over ",
|
|
6429
|
-
|
|
6431
|
+
p.label.toLowerCase(),
|
|
6430
6432
|
")"
|
|
6431
6433
|
] }),
|
|
6432
6434
|
/* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
|
|
6433
|
-
ze(
|
|
6435
|
+
ze(b),
|
|
6434
6436
|
/* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
|
|
6435
6437
|
"(",
|
|
6436
|
-
ze(
|
|
6438
|
+
ze(m.total_usd),
|
|
6437
6439
|
" over ",
|
|
6438
|
-
|
|
6440
|
+
p.label.toLowerCase(),
|
|
6439
6441
|
")"
|
|
6440
6442
|
] })
|
|
6441
6443
|
] })
|
|
6442
6444
|
] })
|
|
6443
6445
|
),
|
|
6444
6446
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-4", children: [
|
|
6445
|
-
t ? /* @__PURE__ */ e(
|
|
6446
|
-
/* @__PURE__ */ e(
|
|
6447
|
-
/* @__PURE__ */ e(
|
|
6447
|
+
t ? /* @__PURE__ */ e(ut, { label: "Demo spend", value: ze(m.demo_usd) }) : /* @__PURE__ */ e(ut, { label: "Cost", value: ze(m.total_usd) }),
|
|
6448
|
+
/* @__PURE__ */ e(ut, { label: "Calls", value: m.call_count.toLocaleString() }),
|
|
6449
|
+
/* @__PURE__ */ e(ut, { label: "Unique IPs", value: m.unique_ips.toLocaleString() }),
|
|
6448
6450
|
/* @__PURE__ */ e(
|
|
6449
|
-
|
|
6451
|
+
ut,
|
|
6450
6452
|
{
|
|
6451
6453
|
label: "Tokens (in/out)",
|
|
6452
|
-
value: `${
|
|
6454
|
+
value: `${m.prompt_tokens.toLocaleString()} / ${m.completion_tokens.toLocaleString()}`
|
|
6453
6455
|
}
|
|
6454
6456
|
)
|
|
6455
6457
|
] }),
|
|
6456
|
-
Object.keys(
|
|
6458
|
+
Object.keys(m.by_provider).length > 0 && /* @__PURE__ */ r("div", { children: [
|
|
6457
6459
|
/* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-gray-500", children: "By provider" }),
|
|
6458
6460
|
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-gray-200", children: /* @__PURE__ */ r("table", { className: "w-full text-sm", children: [
|
|
6459
6461
|
/* @__PURE__ */ e("thead", { className: "bg-gray-50 text-xs uppercase tracking-wide text-gray-500", children: /* @__PURE__ */ r("tr", { children: [
|
|
@@ -6463,12 +6465,12 @@ function Ci({ demoActive: t }) {
|
|
|
6463
6465
|
/* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Prompt tok" }),
|
|
6464
6466
|
/* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Completion tok" })
|
|
6465
6467
|
] }) }),
|
|
6466
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: Object.entries(
|
|
6468
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: Object.entries(m.by_provider).map(([u, h]) => /* @__PURE__ */ r("tr", { children: [
|
|
6467
6469
|
/* @__PURE__ */ e("td", { className: "px-3 py-2 font-medium text-gray-900", children: u }),
|
|
6468
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: ze(
|
|
6469
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children:
|
|
6470
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children:
|
|
6471
|
-
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children:
|
|
6470
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: ze(h.cost_usd) }),
|
|
6471
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.call_count.toLocaleString() }),
|
|
6472
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.prompt_tokens.toLocaleString() }),
|
|
6473
|
+
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.completion_tokens.toLocaleString() })
|
|
6472
6474
|
] }, u)) })
|
|
6473
6475
|
] }) })
|
|
6474
6476
|
] }),
|
|
@@ -6481,49 +6483,66 @@ function Ci({ demoActive: t }) {
|
|
|
6481
6483
|
/* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Cost" }),
|
|
6482
6484
|
/* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Calls" })
|
|
6483
6485
|
] }) }),
|
|
6484
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: o.top_ips_24h.map((u,
|
|
6486
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: o.top_ips_24h.map((u, h) => /* @__PURE__ */ r("tr", { children: [
|
|
6485
6487
|
/* @__PURE__ */ e("td", { className: "px-3 py-2 font-mono text-xs text-gray-900", children: u.ip }),
|
|
6486
6488
|
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: u.role ?? "—" }),
|
|
6487
6489
|
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: ze(u.cost_usd) }),
|
|
6488
6490
|
/* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: u.call_count.toLocaleString() })
|
|
6489
|
-
] }, `${u.ip}-${u.role ?? ""}-${
|
|
6491
|
+
] }, `${u.ip}-${u.role ?? ""}-${h}`)) })
|
|
6490
6492
|
] }) })
|
|
6491
6493
|
] })
|
|
6492
6494
|
] })
|
|
6493
6495
|
] });
|
|
6494
6496
|
}
|
|
6495
|
-
function
|
|
6497
|
+
function ut({ label: t, value: n }) {
|
|
6496
6498
|
return /* @__PURE__ */ r("div", { className: "rounded-md bg-gray-50 px-3 py-2", children: [
|
|
6497
6499
|
/* @__PURE__ */ e("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: t }),
|
|
6498
6500
|
/* @__PURE__ */ e("div", { className: "mt-0.5 text-sm font-semibold tabular-nums text-gray-900", children: n })
|
|
6499
6501
|
] });
|
|
6500
6502
|
}
|
|
6501
6503
|
function Di() {
|
|
6502
|
-
const { t } =
|
|
6503
|
-
mutationFn: () => O.authChangePassword(
|
|
6504
|
+
const { t } = X(), { user: n } = it(), [a, s] = N(""), [o, i] = N(""), [c, l] = N(""), [g, d] = N(""), [p, m] = N(!1), x = ue({
|
|
6505
|
+
mutationFn: () => O.authChangePassword(a, o),
|
|
6504
6506
|
onSuccess: () => {
|
|
6505
|
-
m(!0),
|
|
6507
|
+
m(!0), d(""), s(""), i(""), l(""), setTimeout(() => m(!1), 4e3);
|
|
6506
6508
|
},
|
|
6507
|
-
onError: (
|
|
6508
|
-
}),
|
|
6509
|
-
if (
|
|
6510
|
-
|
|
6509
|
+
onError: (b) => d(b instanceof Ke ? b.message : t("login.registrationFailed"))
|
|
6510
|
+
}), C = (b) => {
|
|
6511
|
+
if (b.preventDefault(), d(""), m(!1), o !== c) {
|
|
6512
|
+
d(t("login.passwordsNoMatch"));
|
|
6511
6513
|
return;
|
|
6512
6514
|
}
|
|
6513
|
-
if (
|
|
6514
|
-
|
|
6515
|
+
if (o.length < 6) {
|
|
6516
|
+
d(t("login.passwordTooShort"));
|
|
6515
6517
|
return;
|
|
6516
6518
|
}
|
|
6517
|
-
|
|
6519
|
+
x.mutate();
|
|
6518
6520
|
};
|
|
6519
|
-
return /* @__PURE__ */ e($, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit:
|
|
6521
|
+
return /* @__PURE__ */ e($, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit: C, className: "max-w-sm space-y-3", children: [
|
|
6522
|
+
/* @__PURE__ */ e(
|
|
6523
|
+
"input",
|
|
6524
|
+
{
|
|
6525
|
+
type: "text",
|
|
6526
|
+
name: "username",
|
|
6527
|
+
id: "username",
|
|
6528
|
+
autoComplete: "username",
|
|
6529
|
+
value: (n == null ? void 0 : n.email) || "",
|
|
6530
|
+
readOnly: !0,
|
|
6531
|
+
tabIndex: -1,
|
|
6532
|
+
"aria-hidden": "true",
|
|
6533
|
+
style: { display: "none" }
|
|
6534
|
+
}
|
|
6535
|
+
),
|
|
6520
6536
|
/* @__PURE__ */ e(
|
|
6521
6537
|
Y,
|
|
6522
6538
|
{
|
|
6523
6539
|
label: t("settings.currentPassword"),
|
|
6540
|
+
id: "current-password",
|
|
6541
|
+
name: "current-password",
|
|
6524
6542
|
type: "password",
|
|
6525
|
-
|
|
6526
|
-
|
|
6543
|
+
autoComplete: "current-password",
|
|
6544
|
+
value: a,
|
|
6545
|
+
onChange: (b) => s(b.target.value),
|
|
6527
6546
|
required: !0
|
|
6528
6547
|
}
|
|
6529
6548
|
),
|
|
@@ -6531,9 +6550,12 @@ function Di() {
|
|
|
6531
6550
|
Y,
|
|
6532
6551
|
{
|
|
6533
6552
|
label: t("settings.newPassword"),
|
|
6553
|
+
id: "new-password",
|
|
6554
|
+
name: "new-password",
|
|
6534
6555
|
type: "password",
|
|
6535
|
-
|
|
6536
|
-
|
|
6556
|
+
autoComplete: "new-password",
|
|
6557
|
+
value: o,
|
|
6558
|
+
onChange: (b) => i(b.target.value),
|
|
6537
6559
|
required: !0
|
|
6538
6560
|
}
|
|
6539
6561
|
),
|
|
@@ -6541,19 +6563,22 @@ function Di() {
|
|
|
6541
6563
|
Y,
|
|
6542
6564
|
{
|
|
6543
6565
|
label: t("settings.confirmNewPassword"),
|
|
6566
|
+
id: "confirm-password",
|
|
6567
|
+
name: "confirm-password",
|
|
6544
6568
|
type: "password",
|
|
6545
|
-
|
|
6546
|
-
|
|
6569
|
+
autoComplete: "new-password",
|
|
6570
|
+
value: c,
|
|
6571
|
+
onChange: (b) => l(b.target.value),
|
|
6547
6572
|
required: !0
|
|
6548
6573
|
}
|
|
6549
6574
|
),
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
/* @__PURE__ */ e(
|
|
6575
|
+
g && /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: g }),
|
|
6576
|
+
p && /* @__PURE__ */ e("p", { className: "text-sm text-green-700", children: t("settings.passwordChanged") }),
|
|
6577
|
+
/* @__PURE__ */ e(Z, { type: "submit", disabled: x.isPending || !a || !o || !c, children: x.isPending ? t("settings.changingPassword") : t("settings.changePassword") })
|
|
6553
6578
|
] }) });
|
|
6554
6579
|
}
|
|
6555
6580
|
function _i() {
|
|
6556
|
-
const { user: t } =
|
|
6581
|
+
const { user: t } = it(), { t: n } = X(), a = Qe(), s = (t == null ? void 0 : t.role) === "admin", { data: o, isLoading: i } = oe({
|
|
6557
6582
|
queryKey: ["settings"],
|
|
6558
6583
|
queryFn: () => O.getSettings()
|
|
6559
6584
|
}), c = ue({
|
|
@@ -6562,12 +6587,12 @@ function _i() {
|
|
|
6562
6587
|
}), { data: l } = oe({
|
|
6563
6588
|
queryKey: ["public-manager"],
|
|
6564
6589
|
queryFn: () => O.getPublicManagerStatus()
|
|
6565
|
-
}), [
|
|
6590
|
+
}), [g, d] = N(!1), p = ue({
|
|
6566
6591
|
mutationFn: () => O.createPublicManager(),
|
|
6567
6592
|
onSuccess: () => {
|
|
6568
6593
|
a.invalidateQueries({ queryKey: ["public-manager"] }), d(!1);
|
|
6569
6594
|
}
|
|
6570
|
-
}),
|
|
6595
|
+
}), m = ue({
|
|
6571
6596
|
mutationFn: () => O.removePublicManager(),
|
|
6572
6597
|
onSuccess: () => a.invalidateQueries({ queryKey: ["public-manager"] })
|
|
6573
6598
|
});
|
|
@@ -6624,6 +6649,7 @@ function _i() {
|
|
|
6624
6649
|
}
|
|
6625
6650
|
)
|
|
6626
6651
|
] }) }),
|
|
6652
|
+
s && /* @__PURE__ */ e(Ci, { demoActive: !!(l != null && l.active) }),
|
|
6627
6653
|
s && /* @__PURE__ */ e($, { title: n("settings.publicTitle"), children: l != null && l.active ? /* @__PURE__ */ r("div", { children: [
|
|
6628
6654
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
6629
6655
|
/* @__PURE__ */ e("span", { className: "inline-block h-2 w-2 rounded-full bg-green-500" }),
|
|
@@ -6633,25 +6659,25 @@ function _i() {
|
|
|
6633
6659
|
/* @__PURE__ */ e(
|
|
6634
6660
|
"button",
|
|
6635
6661
|
{
|
|
6636
|
-
onClick: () =>
|
|
6637
|
-
disabled:
|
|
6662
|
+
onClick: () => m.mutate(),
|
|
6663
|
+
disabled: m.isPending,
|
|
6638
6664
|
className: "mt-3 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-200",
|
|
6639
|
-
children:
|
|
6665
|
+
children: m.isPending ? n("settings.disabling") : n("settings.disablePublic")
|
|
6640
6666
|
}
|
|
6641
6667
|
)
|
|
6642
6668
|
] }) : /* @__PURE__ */ r("div", { children: [
|
|
6643
6669
|
/* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: n("settings.publicInactiveBody") }),
|
|
6644
|
-
|
|
6670
|
+
g ? /* @__PURE__ */ r("div", { className: "mt-3 rounded-lg border border-red-200 bg-red-50 p-4", children: [
|
|
6645
6671
|
/* @__PURE__ */ e("p", { className: "text-sm font-medium text-red-800", children: n("common.areYouSure") }),
|
|
6646
6672
|
/* @__PURE__ */ e("p", { className: "mt-1 text-xs text-red-600", children: n("settings.enableWarning") }),
|
|
6647
6673
|
/* @__PURE__ */ r("div", { className: "mt-3 flex gap-2", children: [
|
|
6648
6674
|
/* @__PURE__ */ e(
|
|
6649
6675
|
"button",
|
|
6650
6676
|
{
|
|
6651
|
-
onClick: () =>
|
|
6652
|
-
disabled:
|
|
6677
|
+
onClick: () => p.mutate(),
|
|
6678
|
+
disabled: p.isPending,
|
|
6653
6679
|
className: "rounded-lg bg-red-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-700",
|
|
6654
|
-
children:
|
|
6680
|
+
children: p.isPending ? n("settings.enabling") : n("settings.yesEnable")
|
|
6655
6681
|
}
|
|
6656
6682
|
),
|
|
6657
6683
|
/* @__PURE__ */ e(
|
|
@@ -6671,8 +6697,7 @@ function _i() {
|
|
|
6671
6697
|
children: n("settings.enablePublic")
|
|
6672
6698
|
}
|
|
6673
6699
|
)
|
|
6674
|
-
] }) })
|
|
6675
|
-
s && /* @__PURE__ */ e(Ci, { demoActive: !!(l != null && l.active) })
|
|
6700
|
+
] }) })
|
|
6676
6701
|
] });
|
|
6677
6702
|
}
|
|
6678
6703
|
const na = {};
|
|
@@ -6779,6 +6804,6 @@ export {
|
|
|
6779
6804
|
Ki as registerNavItem,
|
|
6780
6805
|
Zi as registerRoute,
|
|
6781
6806
|
E as request,
|
|
6782
|
-
|
|
6807
|
+
it as useAuth
|
|
6783
6808
|
};
|
|
6784
6809
|
//# sourceMappingURL=index.js.map
|