@oondemand/oon-core-front 0.3.61 → 0.3.63
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.d.ts +69 -14
- package/dist/index.js +910 -153
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4029,49 +4029,85 @@ function CorePipeline({
|
|
|
4029
4029
|
|
|
4030
4030
|
// src/components/CoreDashboard.tsx
|
|
4031
4031
|
import { Box as Box13, Heading as Heading6, SimpleGrid as SimpleGrid4, Stack as Stack6, Text as Text14 } from "@chakra-ui/react";
|
|
4032
|
-
import {
|
|
4032
|
+
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
4033
4033
|
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4034
|
+
function metricFormat(widget) {
|
|
4035
|
+
if (widget.format) return widget.format;
|
|
4036
|
+
return ["sum", "groupSum"].includes(widget.kind || "") ? "currency" : "number";
|
|
4037
|
+
}
|
|
4038
|
+
function formatMetric(value2, format2) {
|
|
4039
|
+
if (value2 == null || !Number.isFinite(Number(value2))) return "\u2014";
|
|
4040
|
+
if (format2 === "currency") {
|
|
4041
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
4042
|
+
}
|
|
4043
|
+
return new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 2 }).format(Number(value2));
|
|
4044
|
+
}
|
|
4034
4045
|
function CoreDashboard({ label = "Dashboard", widgets = [] }) {
|
|
4035
|
-
const {
|
|
4036
|
-
const
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
}
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4046
|
+
const { http } = useOonApi();
|
|
4047
|
+
const remoteWidgets = widgets.filter((widget) => widget.kind !== "custom" && widget.model);
|
|
4048
|
+
const metricsQuery = useQuery8({
|
|
4049
|
+
queryKey: ["oon", "dashboard", remoteWidgets],
|
|
4050
|
+
enabled: remoteWidgets.length > 0,
|
|
4051
|
+
staleTime: 60 * 1e3,
|
|
4052
|
+
queryFn: async () => {
|
|
4053
|
+
const response = await http.post("/core/dashboard/query", {
|
|
4054
|
+
queries: remoteWidgets.map(({ id, model, kind, field, groupBy, filters }) => ({
|
|
4055
|
+
id,
|
|
4056
|
+
model,
|
|
4057
|
+
kind: kind || "count",
|
|
4058
|
+
field,
|
|
4059
|
+
groupBy,
|
|
4060
|
+
filters
|
|
4061
|
+
}))
|
|
4062
|
+
});
|
|
4063
|
+
return response.data?.results ?? [];
|
|
4064
|
+
}
|
|
4048
4065
|
});
|
|
4049
|
-
|
|
4066
|
+
const results = new Map((metricsQuery.data ?? []).map((result) => [result.id, result]));
|
|
4050
4067
|
return /* @__PURE__ */ jsxs14(Stack6, { gap: 6, children: [
|
|
4051
|
-
/* @__PURE__ */
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4068
|
+
/* @__PURE__ */ jsxs14(Box13, { children: [
|
|
4069
|
+
/* @__PURE__ */ jsx20(Text14, { fontSize: "xs", fontWeight: "600", color: "brand.600", textTransform: "uppercase", letterSpacing: "0.08em", children: "Vis\xE3o geral" }),
|
|
4070
|
+
/* @__PURE__ */ jsx20(Heading6, { size: "lg", children: label })
|
|
4071
|
+
] }),
|
|
4072
|
+
!widgets.length ? /* @__PURE__ */ jsx20(Text14, { color: "gray.500", children: "Nenhum indicador declarado." }) : null,
|
|
4073
|
+
/* @__PURE__ */ jsx20(SimpleGrid4, { columns: { base: 1, md: 2, lg: 3 }, gap: 4, children: widgets.map((widget) => {
|
|
4074
|
+
if (widget.kind === "custom" && widget.render) {
|
|
4075
|
+
return /* @__PURE__ */ jsx20(Box13, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "lg", bg: "white", p: 5, children: widget.render() }, widget.id);
|
|
4055
4076
|
}
|
|
4056
|
-
const
|
|
4057
|
-
const
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4077
|
+
const result = results.get(widget.id);
|
|
4078
|
+
const grouped = ["groupCount", "groupSum"].includes(widget.kind || "");
|
|
4079
|
+
const format2 = metricFormat(widget);
|
|
4080
|
+
return /* @__PURE__ */ jsxs14(
|
|
4081
|
+
Box13,
|
|
4082
|
+
{
|
|
4083
|
+
gridColumn: grouped ? "1 / -1" : void 0,
|
|
4084
|
+
borderWidth: "1px",
|
|
4085
|
+
borderColor: "gray.200",
|
|
4086
|
+
borderRadius: "lg",
|
|
4087
|
+
bg: "white",
|
|
4088
|
+
p: 5,
|
|
4089
|
+
minH: grouped ? void 0 : "126px",
|
|
4090
|
+
children: [
|
|
4091
|
+
/* @__PURE__ */ jsx20(Text14, { fontSize: "sm", color: "gray.500", children: widget.label }),
|
|
4092
|
+
widget.description ? /* @__PURE__ */ jsx20(Text14, { fontSize: "xs", color: "gray.400", mt: 1, children: widget.description }) : null,
|
|
4093
|
+
metricsQuery.isLoading ? /* @__PURE__ */ jsx20(Heading6, { size: "xl", mt: 2, children: "\u2026" }) : null,
|
|
4094
|
+
metricsQuery.isError ? /* @__PURE__ */ jsx20(Text14, { color: "red.600", mt: 3, children: "N\xE3o foi poss\xEDvel carregar este indicador." }) : null,
|
|
4095
|
+
!metricsQuery.isLoading && !metricsQuery.isError && grouped ? /* @__PURE__ */ jsx20(SimpleGrid4, { columns: { base: 1, md: 2, lg: 3 }, gap: 3, mt: 4, children: (result?.groups ?? []).length ? result?.groups?.map((group) => /* @__PURE__ */ jsxs14(Box13, { borderWidth: "1px", borderColor: "gray.100", borderRadius: "md", p: 3, children: [
|
|
4096
|
+
/* @__PURE__ */ jsx20(Text14, { fontSize: "xs", color: "gray.500", children: group.key }),
|
|
4097
|
+
/* @__PURE__ */ jsx20(Heading6, { size: "md", mt: 1, children: formatMetric(group.value, format2) })
|
|
4098
|
+
] }, group.key)) : /* @__PURE__ */ jsx20(Text14, { color: "gray.500", children: "Nenhum ticket encontrado." }) }) : null,
|
|
4099
|
+
!metricsQuery.isLoading && !metricsQuery.isError && !grouped ? /* @__PURE__ */ jsx20(Heading6, { size: "xl", mt: 2, children: formatMetric(result?.value, format2) }) : null
|
|
4100
|
+
]
|
|
4101
|
+
},
|
|
4102
|
+
widget.id
|
|
4103
|
+
);
|
|
4062
4104
|
}) })
|
|
4063
4105
|
] });
|
|
4064
4106
|
}
|
|
4065
|
-
function formatWidget(value2, kind, field) {
|
|
4066
|
-
if (value2 == null) return "\u2014";
|
|
4067
|
-
if (kind === "sum" && field?.toLowerCase().includes("valor") || kind === "sum") {
|
|
4068
|
-
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
4069
|
-
}
|
|
4070
|
-
return String(value2);
|
|
4071
|
-
}
|
|
4072
4107
|
|
|
4073
4108
|
// src/components/ui-v2/CorePage.tsx
|
|
4074
|
-
import { Box as Box16, Heading as Heading8, Stack as Stack7, Text as Text17 } from "@chakra-ui/react";
|
|
4109
|
+
import { Box as Box16, Button as Button11, Flex as Flex10, Heading as Heading8, Stack as Stack7, Text as Text17 } from "@chakra-ui/react";
|
|
4110
|
+
import { useNavigate } from "react-router-dom";
|
|
4075
4111
|
|
|
4076
4112
|
// src/security/PermissionGate.tsx
|
|
4077
4113
|
import { Fragment as Fragment2, jsx as jsx21 } from "react/jsx-runtime";
|
|
@@ -4180,6 +4216,7 @@ function requiredAccess(source) {
|
|
|
4180
4216
|
return values.length ? values : void 0;
|
|
4181
4217
|
}
|
|
4182
4218
|
function CoreBlock({ block, registry }) {
|
|
4219
|
+
const navigate = useNavigate();
|
|
4183
4220
|
if (block.hidden) return null;
|
|
4184
4221
|
const content = (() => {
|
|
4185
4222
|
switch (block.type) {
|
|
@@ -4193,6 +4230,40 @@ function CoreBlock({ block, registry }) {
|
|
|
4193
4230
|
const Component = resolveComponent(registry, block.renderer, "cardRenderers");
|
|
4194
4231
|
return Component ? /* @__PURE__ */ jsx24(Component, { block, model: block.model }) : /* @__PURE__ */ jsx24(CoreCards, { model: block.model, renderer: block.renderer });
|
|
4195
4232
|
}
|
|
4233
|
+
case "navigation.cards":
|
|
4234
|
+
return /* @__PURE__ */ jsx24(Flex10, { gap: 4, wrap: "wrap", children: block.cards.map((card) => /* @__PURE__ */ jsx24(
|
|
4235
|
+
Box16,
|
|
4236
|
+
{
|
|
4237
|
+
minW: "260px",
|
|
4238
|
+
flex: `1 1 calc(${100 / (block.columns ?? 2)}% - 16px)`,
|
|
4239
|
+
borderWidth: "1px",
|
|
4240
|
+
borderRadius: "lg",
|
|
4241
|
+
bg: "white",
|
|
4242
|
+
p: 5,
|
|
4243
|
+
children: /* @__PURE__ */ jsxs17(Stack7, { gap: 3, height: "100%", children: [
|
|
4244
|
+
/* @__PURE__ */ jsxs17(Box16, { flex: "1", children: [
|
|
4245
|
+
/* @__PURE__ */ jsx24(Heading8, { size: "md", mb: 2, children: card.title }),
|
|
4246
|
+
card.description ? /* @__PURE__ */ jsx24(Text17, { color: "gray.600", children: card.description }) : null
|
|
4247
|
+
] }),
|
|
4248
|
+
/* @__PURE__ */ jsx24(
|
|
4249
|
+
Button11,
|
|
4250
|
+
{
|
|
4251
|
+
alignSelf: "flex-start",
|
|
4252
|
+
variant: "outline",
|
|
4253
|
+
onClick: () => {
|
|
4254
|
+
if (card.external) {
|
|
4255
|
+
window.open(card.href, "_blank", "noopener,noreferrer");
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
navigate(card.href);
|
|
4259
|
+
},
|
|
4260
|
+
children: card.actionLabel || "Abrir"
|
|
4261
|
+
}
|
|
4262
|
+
)
|
|
4263
|
+
] })
|
|
4264
|
+
},
|
|
4265
|
+
`${card.title}:${card.href}`
|
|
4266
|
+
)) });
|
|
4196
4267
|
case "section":
|
|
4197
4268
|
return /* @__PURE__ */ jsxs17(Box16, { children: [
|
|
4198
4269
|
/* @__PURE__ */ jsx24(Heading8, { size: "md", mb: block.description ? 1 : 4, children: block.title }),
|
|
@@ -4323,7 +4394,7 @@ function pageToRoute(page, registry) {
|
|
|
4323
4394
|
};
|
|
4324
4395
|
}
|
|
4325
4396
|
function pageToMenu(page) {
|
|
4326
|
-
if (
|
|
4397
|
+
if (!page.label) return null;
|
|
4327
4398
|
return {
|
|
4328
4399
|
label: page.label,
|
|
4329
4400
|
href: page.path,
|
|
@@ -4331,17 +4402,21 @@ function pageToMenu(page) {
|
|
|
4331
4402
|
section: page.section,
|
|
4332
4403
|
permissions: requiredPermissions(page),
|
|
4333
4404
|
capabilities: page.capabilities,
|
|
4405
|
+
hidden: page.hidden,
|
|
4334
4406
|
order: page.order
|
|
4335
4407
|
};
|
|
4336
4408
|
}
|
|
4337
4409
|
function viewToMenu(view) {
|
|
4410
|
+
const extended = view;
|
|
4338
4411
|
return {
|
|
4339
4412
|
label: viewLabel(view),
|
|
4340
4413
|
href: viewPath(view),
|
|
4341
4414
|
icon: view.icon,
|
|
4342
4415
|
section: view.section,
|
|
4343
4416
|
permissions: requiredPermissions(view),
|
|
4344
|
-
capabilities: "capabilities" in view ? view.capabilities : void 0
|
|
4417
|
+
capabilities: "capabilities" in view ? view.capabilities : void 0,
|
|
4418
|
+
hidden: extended.hidden,
|
|
4419
|
+
order: extended.order
|
|
4345
4420
|
};
|
|
4346
4421
|
}
|
|
4347
4422
|
function resolveRegistry(config) {
|
|
@@ -4394,11 +4469,11 @@ import {
|
|
|
4394
4469
|
} from "react-router-dom";
|
|
4395
4470
|
|
|
4396
4471
|
// src/shell/DefaultShell.tsx
|
|
4397
|
-
import { Box as Box18, Button as
|
|
4398
|
-
import { Outlet, useNavigate } from "react-router-dom";
|
|
4472
|
+
import { Box as Box18, Button as Button12, Flex as Flex12, Spacer as Spacer2, Text as Text19 } from "@chakra-ui/react";
|
|
4473
|
+
import { Outlet, useNavigate as useNavigate2 } from "react-router-dom";
|
|
4399
4474
|
|
|
4400
4475
|
// src/shell/Sidebar.tsx
|
|
4401
|
-
import { Box as Box17, Flex as
|
|
4476
|
+
import { Box as Box17, Flex as Flex11, Image, Stack as Stack8, Text as Text18 } from "@chakra-ui/react";
|
|
4402
4477
|
import { NavLink } from "react-router-dom";
|
|
4403
4478
|
import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4404
4479
|
function groupBySection(items) {
|
|
@@ -4429,9 +4504,9 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4429
4504
|
alignSelf: "flex-start",
|
|
4430
4505
|
overflowY: "auto",
|
|
4431
4506
|
children: [
|
|
4432
|
-
/* @__PURE__ */ jsxs18(
|
|
4507
|
+
/* @__PURE__ */ jsxs18(Flex11, { align: "center", gap: 3, mb: 6, px: { base: 1, lg: 2 }, minH: "42px", children: [
|
|
4433
4508
|
app.logo ? /* @__PURE__ */ jsx26(Image, { src: app.logo, alt: app.name, maxH: "36px", maxW: { base: "44px", lg: "150px" }, objectFit: "contain" }) : /* @__PURE__ */ jsx26(
|
|
4434
|
-
|
|
4509
|
+
Flex11,
|
|
4435
4510
|
{
|
|
4436
4511
|
w: "38px",
|
|
4437
4512
|
h: "38px",
|
|
@@ -4470,7 +4545,7 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4470
4545
|
const CustomMenuItem = resolveComponent(registry, item.renderer, "menuRenderers");
|
|
4471
4546
|
if (CustomMenuItem) return /* @__PURE__ */ jsx26(CustomMenuItem, { item }, item.href);
|
|
4472
4547
|
return /* @__PURE__ */ jsx26(NavLink, { to: item.href, end: item.href === "/", title: item.label, children: ({ isActive }) => /* @__PURE__ */ jsxs18(
|
|
4473
|
-
|
|
4548
|
+
Flex11,
|
|
4474
4549
|
{
|
|
4475
4550
|
align: "center",
|
|
4476
4551
|
justify: { base: "center", lg: "flex-start" },
|
|
@@ -4502,7 +4577,7 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4502
4577
|
// package.json
|
|
4503
4578
|
var package_default = {
|
|
4504
4579
|
name: "@oondemand/oon-core-front",
|
|
4505
|
-
version: "0.3.
|
|
4580
|
+
version: "0.3.63",
|
|
4506
4581
|
repository: {
|
|
4507
4582
|
type: "git",
|
|
4508
4583
|
url: "git+https://github.com/oondemand/oon-platform.git",
|
|
@@ -4665,7 +4740,7 @@ function resolveSettingsHref(menu) {
|
|
|
4665
4740
|
}
|
|
4666
4741
|
function CoreTopbar({ app, menu }) {
|
|
4667
4742
|
const { user, logout, hasPermission } = useOonAuth();
|
|
4668
|
-
const navigate =
|
|
4743
|
+
const navigate = useNavigate2();
|
|
4669
4744
|
const metadataQuery = useCoreMetadata();
|
|
4670
4745
|
const runtime = resolveRuntimeVersionInfo(app, metadataQuery.data);
|
|
4671
4746
|
const centralVersion = runtime.centralVersion ?? "n\xE3o informada";
|
|
@@ -4687,10 +4762,10 @@ function CoreTopbar({ app, menu }) {
|
|
|
4687
4762
|
runtime.startedAt ? `Backend iniciado ${formatRuntimeDate(runtime.startedAt)}` : void 0
|
|
4688
4763
|
].filter(Boolean).join(" \xB7 ");
|
|
4689
4764
|
const settingsHref = resolveSettingsHref(
|
|
4690
|
-
menu.filter((item) =>
|
|
4765
|
+
menu.filter((item) => hasPermission(item.permissions))
|
|
4691
4766
|
);
|
|
4692
4767
|
return /* @__PURE__ */ jsxs19(
|
|
4693
|
-
|
|
4768
|
+
Flex12,
|
|
4694
4769
|
{
|
|
4695
4770
|
as: "header",
|
|
4696
4771
|
align: "center",
|
|
@@ -4729,13 +4804,13 @@ function CoreTopbar({ app, menu }) {
|
|
|
4729
4804
|
publicationParts.length ? /* @__PURE__ */ jsx27(Text19, { fontSize: "10px", color: "gray.500", lineHeight: "1.35", children: publicationParts.join(" \xB7 ") }) : null
|
|
4730
4805
|
] }),
|
|
4731
4806
|
/* @__PURE__ */ jsx27(Spacer2, {}),
|
|
4732
|
-
user ? /* @__PURE__ */ jsxs19(
|
|
4807
|
+
user ? /* @__PURE__ */ jsxs19(Flex12, { align: "center", gap: 3, children: [
|
|
4733
4808
|
/* @__PURE__ */ jsxs19(Box18, { textAlign: "right", display: { base: "none", md: "block" }, children: [
|
|
4734
4809
|
/* @__PURE__ */ jsx27(Text19, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: user.nome }),
|
|
4735
4810
|
user.email ? /* @__PURE__ */ jsx27(Text19, { fontSize: "xs", color: "gray.500", children: user.email }) : null
|
|
4736
4811
|
] }),
|
|
4737
4812
|
settingsHref ? /* @__PURE__ */ jsx27(
|
|
4738
|
-
|
|
4813
|
+
Button12,
|
|
4739
4814
|
{
|
|
4740
4815
|
size: "sm",
|
|
4741
4816
|
variant: "outline",
|
|
@@ -4750,7 +4825,7 @@ function CoreTopbar({ app, menu }) {
|
|
|
4750
4825
|
}
|
|
4751
4826
|
) : null,
|
|
4752
4827
|
/* @__PURE__ */ jsx27(
|
|
4753
|
-
|
|
4828
|
+
Button12,
|
|
4754
4829
|
{
|
|
4755
4830
|
size: "sm",
|
|
4756
4831
|
variant: "outline",
|
|
@@ -4792,7 +4867,7 @@ function DefaultShell({
|
|
|
4792
4867
|
}) {
|
|
4793
4868
|
const portal = layout?.shell === "portal" || layout?.shell === "content-only";
|
|
4794
4869
|
const mainPadding = portal ? { base: 4, lg: 10 } : { base: 4, lg: 6 };
|
|
4795
|
-
return /* @__PURE__ */ jsxs19(
|
|
4870
|
+
return /* @__PURE__ */ jsxs19(Flex12, { align: "stretch", minH: "100vh", bg: portal ? "white" : "#F8F9FA", children: [
|
|
4796
4871
|
/* @__PURE__ */ jsx27(
|
|
4797
4872
|
Slot,
|
|
4798
4873
|
{
|
|
@@ -4803,7 +4878,7 @@ function DefaultShell({
|
|
|
4803
4878
|
menu
|
|
4804
4879
|
}
|
|
4805
4880
|
),
|
|
4806
|
-
/* @__PURE__ */ jsxs19(
|
|
4881
|
+
/* @__PURE__ */ jsxs19(Flex12, { direction: "column", flex: "1", minW: 0, children: [
|
|
4807
4882
|
/* @__PURE__ */ jsx27(
|
|
4808
4883
|
Slot,
|
|
4809
4884
|
{
|
|
@@ -4845,17 +4920,17 @@ function AuthenticatedLayout({ app, menu, layout, registry }) {
|
|
|
4845
4920
|
}
|
|
4846
4921
|
|
|
4847
4922
|
// src/security/AccessDeniedPage.tsx
|
|
4848
|
-
import { Box as Box19, Button as
|
|
4849
|
-
import { useNavigate as
|
|
4923
|
+
import { Box as Box19, Button as Button13, Flex as Flex13, Heading as Heading9, Text as Text20, VStack } from "@chakra-ui/react";
|
|
4924
|
+
import { useNavigate as useNavigate3 } from "react-router-dom";
|
|
4850
4925
|
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4851
4926
|
function AccessDeniedPage({ app }) {
|
|
4852
4927
|
const { logout } = useOonAuth();
|
|
4853
|
-
const navigate =
|
|
4928
|
+
const navigate = useNavigate3();
|
|
4854
4929
|
function useAnotherAccount() {
|
|
4855
4930
|
logout();
|
|
4856
4931
|
navigate("/login", { replace: true });
|
|
4857
4932
|
}
|
|
4858
|
-
return /* @__PURE__ */ jsx29(
|
|
4933
|
+
return /* @__PURE__ */ jsx29(Flex13, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx29(
|
|
4859
4934
|
Box19,
|
|
4860
4935
|
{
|
|
4861
4936
|
width: "100%",
|
|
@@ -4904,7 +4979,7 @@ function AccessDeniedPage({ app }) {
|
|
|
4904
4979
|
] })
|
|
4905
4980
|
] }),
|
|
4906
4981
|
/* @__PURE__ */ jsx29(
|
|
4907
|
-
|
|
4982
|
+
Button13,
|
|
4908
4983
|
{
|
|
4909
4984
|
alignSelf: "flex-start",
|
|
4910
4985
|
bg: "#07262E",
|
|
@@ -4961,8 +5036,8 @@ function AppAccessGuard({ children }) {
|
|
|
4961
5036
|
import { useState as useState12 } from "react";
|
|
4962
5037
|
import {
|
|
4963
5038
|
Box as Box20,
|
|
4964
|
-
Button as
|
|
4965
|
-
Flex as
|
|
5039
|
+
Button as Button14,
|
|
5040
|
+
Flex as Flex14,
|
|
4966
5041
|
Heading as Heading10,
|
|
4967
5042
|
Input as Input6,
|
|
4968
5043
|
Text as Text21,
|
|
@@ -5008,7 +5083,7 @@ function LoginPage({ app }) {
|
|
|
5008
5083
|
setSubmitting(false);
|
|
5009
5084
|
}
|
|
5010
5085
|
}
|
|
5011
|
-
return /* @__PURE__ */ jsx31(
|
|
5086
|
+
return /* @__PURE__ */ jsx31(Flex14, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx31(
|
|
5012
5087
|
Box20,
|
|
5013
5088
|
{
|
|
5014
5089
|
width: "100%",
|
|
@@ -5079,7 +5154,7 @@ function LoginPage({ app }) {
|
|
|
5079
5154
|
}
|
|
5080
5155
|
) : null,
|
|
5081
5156
|
/* @__PURE__ */ jsx31(
|
|
5082
|
-
|
|
5157
|
+
Button14,
|
|
5083
5158
|
{
|
|
5084
5159
|
type: "submit",
|
|
5085
5160
|
bg: "#07262E",
|
|
@@ -5096,7 +5171,7 @@ function LoginPage({ app }) {
|
|
|
5096
5171
|
|
|
5097
5172
|
// src/security/ActivationPage.tsx
|
|
5098
5173
|
import { useEffect as useEffect8, useState as useState13 } from "react";
|
|
5099
|
-
import { Box as Box21, Button as
|
|
5174
|
+
import { Box as Box21, Button as Button15, Heading as Heading11, Input as Input7, Text as Text22, VStack as VStack3 } from "@chakra-ui/react";
|
|
5100
5175
|
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
5101
5176
|
function encodeBasicCredentials2(email, password) {
|
|
5102
5177
|
const bytes = new TextEncoder().encode(`${email}:${password}`);
|
|
@@ -5294,7 +5369,7 @@ function ActivationPage() {
|
|
|
5294
5369
|
)
|
|
5295
5370
|
] }),
|
|
5296
5371
|
/* @__PURE__ */ jsx32(
|
|
5297
|
-
|
|
5372
|
+
Button15,
|
|
5298
5373
|
{
|
|
5299
5374
|
colorPalette: "blue",
|
|
5300
5375
|
onClick: activateDevLocal,
|
|
@@ -5304,7 +5379,7 @@ function ActivationPage() {
|
|
|
5304
5379
|
}
|
|
5305
5380
|
),
|
|
5306
5381
|
/* @__PURE__ */ jsx32(
|
|
5307
|
-
|
|
5382
|
+
Button15,
|
|
5308
5383
|
{
|
|
5309
5384
|
variant: "outline",
|
|
5310
5385
|
onClick: () => setShowCodeFlow(true),
|
|
@@ -5385,7 +5460,7 @@ function ActivationPage() {
|
|
|
5385
5460
|
)
|
|
5386
5461
|
] }),
|
|
5387
5462
|
/* @__PURE__ */ jsx32(
|
|
5388
|
-
|
|
5463
|
+
Button15,
|
|
5389
5464
|
{
|
|
5390
5465
|
colorPalette: "blue",
|
|
5391
5466
|
onClick: activateRoot,
|
|
@@ -5438,7 +5513,7 @@ function ActivationPage() {
|
|
|
5438
5513
|
}
|
|
5439
5514
|
),
|
|
5440
5515
|
/* @__PURE__ */ jsx32(
|
|
5441
|
-
|
|
5516
|
+
Button15,
|
|
5442
5517
|
{
|
|
5443
5518
|
onClick: validateCode,
|
|
5444
5519
|
loading: submitting,
|
|
@@ -5447,7 +5522,7 @@ function ActivationPage() {
|
|
|
5447
5522
|
}
|
|
5448
5523
|
),
|
|
5449
5524
|
isDevelopmentMember ? /* @__PURE__ */ jsx32(
|
|
5450
|
-
|
|
5525
|
+
Button15,
|
|
5451
5526
|
{
|
|
5452
5527
|
variant: "outline",
|
|
5453
5528
|
onClick: () => setShowCodeFlow(false),
|
|
@@ -5459,22 +5534,22 @@ function ActivationPage() {
|
|
|
5459
5534
|
step === 2 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
5460
5535
|
/* @__PURE__ */ jsx32(Heading11, { size: "md", children: "Confirma\xE7\xE3o" }),
|
|
5461
5536
|
/* @__PURE__ */ jsx32("pre", { children: JSON.stringify(preview, null, 2) }),
|
|
5462
|
-
/* @__PURE__ */ jsx32(
|
|
5537
|
+
/* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(3), children: "Continuar" })
|
|
5463
5538
|
] }),
|
|
5464
5539
|
step === 3 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
5465
5540
|
config.globalFields.map(
|
|
5466
5541
|
(field) => renderField(field, global, setGlobal)
|
|
5467
5542
|
),
|
|
5468
|
-
/* @__PURE__ */ jsx32(
|
|
5543
|
+
/* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(4), children: "Continuar" })
|
|
5469
5544
|
] }),
|
|
5470
5545
|
step === 4 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
5471
5546
|
config.appFields.length ? config.appFields.map((field) => renderField(field, app, setApp)) : /* @__PURE__ */ jsx32(Text22, { children: "Nenhum par\xE2metro adicional declarado." }),
|
|
5472
|
-
/* @__PURE__ */ jsx32(
|
|
5547
|
+
/* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(5), children: "Revisar" })
|
|
5473
5548
|
] }),
|
|
5474
5549
|
step === 5 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
5475
5550
|
/* @__PURE__ */ jsx32(Text22, { children: "Ao confirmar, o c\xF3digo ser\xE1 consumido e a inst\xE2ncia ser\xE1 registrada no Ecossistema Oon." }),
|
|
5476
5551
|
/* @__PURE__ */ jsx32(
|
|
5477
|
-
|
|
5552
|
+
Button15,
|
|
5478
5553
|
{
|
|
5479
5554
|
colorPalette: "blue",
|
|
5480
5555
|
onClick: completeMemberActivation,
|
|
@@ -5757,6 +5832,19 @@ function mergeRegistry(manifestRegistry, runtimeRegistry, customComponents) {
|
|
|
5757
5832
|
}
|
|
5758
5833
|
function manifestToConfig(manifest, runtime) {
|
|
5759
5834
|
const views = [];
|
|
5835
|
+
for (const dashboard of manifest.dashboards ?? []) {
|
|
5836
|
+
const view = {
|
|
5837
|
+
type: "dashboard",
|
|
5838
|
+
id: dashboard.id,
|
|
5839
|
+
label: dashboard.label,
|
|
5840
|
+
path: dashboard.path,
|
|
5841
|
+
section: dashboard.section,
|
|
5842
|
+
hidden: dashboard.hidden,
|
|
5843
|
+
order: dashboard.order,
|
|
5844
|
+
widgets: dashboard.widgets
|
|
5845
|
+
};
|
|
5846
|
+
views.push(view);
|
|
5847
|
+
}
|
|
5760
5848
|
for (const c of manifest.collections ?? []) {
|
|
5761
5849
|
const view = {
|
|
5762
5850
|
type: "collection",
|
|
@@ -5765,6 +5853,7 @@ function manifestToConfig(manifest, runtime) {
|
|
|
5765
5853
|
path: c.path,
|
|
5766
5854
|
label: c.label,
|
|
5767
5855
|
section: c.section,
|
|
5856
|
+
hidden: c.hidden,
|
|
5768
5857
|
form: c.form,
|
|
5769
5858
|
list: c.list,
|
|
5770
5859
|
relations: c.relations,
|
|
@@ -5853,12 +5942,12 @@ function startFromManifest(manifest, runtime) {
|
|
|
5853
5942
|
}
|
|
5854
5943
|
|
|
5855
5944
|
// src/modules/integrations.tsx
|
|
5856
|
-
import { Stack as
|
|
5945
|
+
import { Stack as Stack12 } from "@chakra-ui/react";
|
|
5857
5946
|
|
|
5858
5947
|
// src/components/CoreIntegration.tsx
|
|
5859
5948
|
import { useEffect as useEffect9, useState as useState14 } from "react";
|
|
5860
|
-
import { Badge as Badge5, Box as Box22, Button as
|
|
5861
|
-
import { useMutation as useMutation4, useQuery as
|
|
5949
|
+
import { Badge as Badge5, Box as Box22, Button as Button16, Flex as Flex15, Heading as Heading12, Input as Input8, Stack as Stack9, Text as Text23 } from "@chakra-ui/react";
|
|
5950
|
+
import { useMutation as useMutation4, useQuery as useQuery9 } from "@tanstack/react-query";
|
|
5862
5951
|
import { jsx as jsx38, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5863
5952
|
function dateTime(value2) {
|
|
5864
5953
|
if (!value2) return "\u2014";
|
|
@@ -5958,7 +6047,7 @@ function ExecutionDetails({ execution }) {
|
|
|
5958
6047
|
return /* @__PURE__ */ jsx38(Box22, { mt: 3, pt: 3, borderTopWidth: "1px", borderColor: "gray.100", children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
|
|
5959
6048
|
summaryEntries.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
|
|
5960
6049
|
/* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", mb: 2, children: "Resumo da execu\xE7\xE3o" }),
|
|
5961
|
-
/* @__PURE__ */ jsx38(
|
|
6050
|
+
/* @__PURE__ */ jsx38(Flex15, { gap: 2, wrap: "wrap", children: summaryEntries.map(([key, value2]) => /* @__PURE__ */ jsxs23(
|
|
5962
6051
|
Badge5,
|
|
5963
6052
|
{
|
|
5964
6053
|
variant: "outline",
|
|
@@ -5973,7 +6062,7 @@ function ExecutionDetails({ execution }) {
|
|
|
5973
6062
|
)) })
|
|
5974
6063
|
] }) : null,
|
|
5975
6064
|
diagnostics.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
|
|
5976
|
-
/* @__PURE__ */ jsxs23(
|
|
6065
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 2, mb: 2, wrap: "wrap", children: [
|
|
5977
6066
|
/* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", children: "Erros por registro" }),
|
|
5978
6067
|
/* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.500", children: [
|
|
5979
6068
|
execution.errorCount ?? diagnostics.length,
|
|
@@ -6031,11 +6120,11 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6031
6120
|
appSecret: "",
|
|
6032
6121
|
webhookToken: ""
|
|
6033
6122
|
});
|
|
6034
|
-
const configuration =
|
|
6123
|
+
const configuration = useQuery9({
|
|
6035
6124
|
queryKey: ["core-integrations", provider.key, "configuration"],
|
|
6036
6125
|
queryFn: async () => (await http.get(`/integrations/providers/${provider.key}/configuration`)).data?.instances ?? []
|
|
6037
6126
|
});
|
|
6038
|
-
const mappings =
|
|
6127
|
+
const mappings = useQuery9({
|
|
6039
6128
|
queryKey: ["core-integrations", provider.key, "mappings"],
|
|
6040
6129
|
queryFn: async () => (await http.get(`/integrations/providers/${provider.key}/mappings`)).data
|
|
6041
6130
|
});
|
|
@@ -6088,12 +6177,12 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6088
6177
|
webhooks: mappings.data?.webhooks?.length ?? 0
|
|
6089
6178
|
};
|
|
6090
6179
|
return /* @__PURE__ */ jsx38(Box22, { borderTopWidth: "1px", borderColor: "gray.100", pt: 4, children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
|
|
6091
|
-
/* @__PURE__ */ jsxs23(
|
|
6180
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6092
6181
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6093
6182
|
/* @__PURE__ */ jsx38(Text23, { fontWeight: "semibold", children: "Configura\xE7\xE3o" }),
|
|
6094
6183
|
/* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. Segredos gravados nunca s\xE3o devolvidos ao navegador." })
|
|
6095
6184
|
] }),
|
|
6096
|
-
/* @__PURE__ */ jsxs23(
|
|
6185
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 2, wrap: "wrap", children: [
|
|
6097
6186
|
/* @__PURE__ */ jsxs23(Badge5, { variant: "outline", children: [
|
|
6098
6187
|
mappingCounts.chamadas,
|
|
6099
6188
|
" chamadas"
|
|
@@ -6108,7 +6197,7 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6108
6197
|
] })
|
|
6109
6198
|
] })
|
|
6110
6199
|
] }),
|
|
6111
|
-
/* @__PURE__ */ jsxs23(
|
|
6200
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
|
|
6112
6201
|
/* @__PURE__ */ jsxs23(Box22, { minW: "180px", flex: "1", children: [
|
|
6113
6202
|
/* @__PURE__ */ jsx38(Text23, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
|
|
6114
6203
|
/* @__PURE__ */ jsx38(
|
|
@@ -6170,7 +6259,7 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6170
6259
|
}
|
|
6171
6260
|
)
|
|
6172
6261
|
] }),
|
|
6173
|
-
/* @__PURE__ */ jsxs23(
|
|
6262
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
|
|
6174
6263
|
/* @__PURE__ */ jsxs23(Box22, { minW: "220px", flex: "1", children: [
|
|
6175
6264
|
/* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.500", mb: 1, children: [
|
|
6176
6265
|
"App Key ",
|
|
@@ -6214,8 +6303,8 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6214
6303
|
)
|
|
6215
6304
|
] })
|
|
6216
6305
|
] }),
|
|
6217
|
-
/* @__PURE__ */ jsxs23(
|
|
6218
|
-
/* @__PURE__ */ jsxs23(
|
|
6306
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6307
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
|
|
6219
6308
|
/* @__PURE__ */ jsxs23("label", { children: [
|
|
6220
6309
|
/* @__PURE__ */ jsx38(
|
|
6221
6310
|
"input",
|
|
@@ -6237,9 +6326,9 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6237
6326
|
dateTime(selected?.lastConnectionTestAt)
|
|
6238
6327
|
] })
|
|
6239
6328
|
] }),
|
|
6240
|
-
/* @__PURE__ */ jsxs23(
|
|
6241
|
-
/* @__PURE__ */ jsx38(
|
|
6242
|
-
/* @__PURE__ */ jsx38(
|
|
6329
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 2, children: [
|
|
6330
|
+
/* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: testConnection.isPending, onClick: () => testConnection.mutate(), children: "Testar conex\xE3o" }),
|
|
6331
|
+
/* @__PURE__ */ jsx38(Button16, { size: "xs", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xE3o" })
|
|
6243
6332
|
] })
|
|
6244
6333
|
] }),
|
|
6245
6334
|
selected?.lastConnectionError ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: selected.lastConnectionError }) : null,
|
|
@@ -6249,15 +6338,15 @@ function ProviderConfigurationPanel({ provider }) {
|
|
|
6249
6338
|
function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
6250
6339
|
const { http } = useOonApi();
|
|
6251
6340
|
const [expandedExecutionId, setExpandedExecutionId] = useState14(null);
|
|
6252
|
-
const providers =
|
|
6341
|
+
const providers = useQuery9({
|
|
6253
6342
|
queryKey: ["core-integrations", "health"],
|
|
6254
6343
|
queryFn: async () => (await http.get("/integrations/health")).data?.results ?? []
|
|
6255
6344
|
});
|
|
6256
|
-
const queue =
|
|
6345
|
+
const queue = useQuery9({
|
|
6257
6346
|
queryKey: ["core-integrations", "queue"],
|
|
6258
6347
|
queryFn: async () => (await http.get("/integrations/queue", { params: { limit: 20 } })).data?.results ?? []
|
|
6259
6348
|
});
|
|
6260
|
-
const history =
|
|
6349
|
+
const history = useQuery9({
|
|
6261
6350
|
queryKey: ["core-integrations", "history"],
|
|
6262
6351
|
queryFn: async () => (await http.get("/integrations/history", { params: { limit: 10 } })).data?.results ?? []
|
|
6263
6352
|
});
|
|
@@ -6308,25 +6397,25 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6308
6397
|
const error = providers.error || queue.error || history.error;
|
|
6309
6398
|
if (error) return /* @__PURE__ */ jsx38(ErrorState, { error });
|
|
6310
6399
|
return /* @__PURE__ */ jsxs23(Stack9, { gap: 6, children: [
|
|
6311
|
-
/* @__PURE__ */ jsxs23(
|
|
6400
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 4, wrap: "wrap", children: [
|
|
6312
6401
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6313
6402
|
/* @__PURE__ */ jsx38(Heading12, { size: "lg", children: label }),
|
|
6314
6403
|
/* @__PURE__ */ jsx38(Text23, { color: "gray.500", children: "Configura\xE7\xE3o, sa\xFAde, filas, eventos e diagn\xF3stico sanitizado por provedor." })
|
|
6315
6404
|
] }),
|
|
6316
|
-
/* @__PURE__ */ jsx38(
|
|
6405
|
+
/* @__PURE__ */ jsx38(Button16, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" })
|
|
6317
6406
|
] }),
|
|
6318
6407
|
/* @__PURE__ */ jsx38(Stack9, { gap: 3, children: (providers.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum provedor registrado." }) : providers.data?.map((provider) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
|
|
6319
|
-
/* @__PURE__ */ jsxs23(
|
|
6408
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6320
6409
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6321
|
-
/* @__PURE__ */ jsxs23(
|
|
6410
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, children: [
|
|
6322
6411
|
/* @__PURE__ */ jsx38(Text23, { fontWeight: "semibold", children: provider.label }),
|
|
6323
6412
|
/* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(provider.status), children: provider.status ?? "\u2014" })
|
|
6324
6413
|
] }),
|
|
6325
6414
|
provider.description ? /* @__PURE__ */ jsx38(Text23, { color: "gray.500", fontSize: "sm", children: provider.description }) : null
|
|
6326
6415
|
] }),
|
|
6327
|
-
/* @__PURE__ */ jsx38(
|
|
6416
|
+
/* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: syncAll.isPending, onClick: () => syncAll.mutate(provider.key), children: "Sincronizar tudo" })
|
|
6328
6417
|
] }),
|
|
6329
|
-
/* @__PURE__ */ jsxs23(
|
|
6418
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
|
|
6330
6419
|
/* @__PURE__ */ jsxs23(Badge5, { colorPalette: countActive(provider.queue) ? "yellow" : "green", children: [
|
|
6331
6420
|
"Fila ativa: ",
|
|
6332
6421
|
countActive(provider.queue)
|
|
@@ -6344,8 +6433,8 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6344
6433
|
"Pend\xEAncia mais antiga: ",
|
|
6345
6434
|
dateTime(provider.oldestPendingAt)
|
|
6346
6435
|
] }),
|
|
6347
|
-
/* @__PURE__ */ jsx38(
|
|
6348
|
-
|
|
6436
|
+
/* @__PURE__ */ jsx38(Flex15, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx38(
|
|
6437
|
+
Button16,
|
|
6349
6438
|
{
|
|
6350
6439
|
size: "xs",
|
|
6351
6440
|
variant: "outline",
|
|
@@ -6359,9 +6448,9 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6359
6448
|
] }) }, provider.key)) }),
|
|
6360
6449
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6361
6450
|
/* @__PURE__ */ jsx38(Heading12, { size: "md", mb: 3, children: "Fila recente" }),
|
|
6362
|
-
/* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (queue.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum ticket de integra\xE7\xE3o." }) : queue.data?.map((ticket) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: /* @__PURE__ */ jsxs23(
|
|
6451
|
+
/* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (queue.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum ticket de integra\xE7\xE3o." }) : queue.data?.map((ticket) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6363
6452
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6364
|
-
/* @__PURE__ */ jsxs23(
|
|
6453
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
|
|
6365
6454
|
/* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: ticket.handler }),
|
|
6366
6455
|
/* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(ticket.status), children: ticket.status }),
|
|
6367
6456
|
/* @__PURE__ */ jsx38(Badge5, { variant: "outline", children: ticket.provider })
|
|
@@ -6375,9 +6464,9 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6375
6464
|
] }),
|
|
6376
6465
|
ticket.lastError?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
|
|
6377
6466
|
] }),
|
|
6378
|
-
/* @__PURE__ */ jsxs23(
|
|
6379
|
-
["Erro tempor\xE1rio", "Erro definitivo", "Arquivado"].includes(ticket.status) ? /* @__PURE__ */ jsx38(
|
|
6380
|
-
["Erro tempor\xE1rio", "Erro definitivo"].includes(ticket.status) ? /* @__PURE__ */ jsx38(
|
|
6467
|
+
/* @__PURE__ */ jsxs23(Flex15, { gap: 2, children: [
|
|
6468
|
+
["Erro tempor\xE1rio", "Erro definitivo", "Arquivado"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: reprocess.isPending, onClick: () => reprocess.mutate(ticket._id), children: "Reprocessar" }) : null,
|
|
6469
|
+
["Erro tempor\xE1rio", "Erro definitivo"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: archive.isPending, onClick: () => archive.mutate(ticket._id), children: "Arquivar" }) : null
|
|
6381
6470
|
] })
|
|
6382
6471
|
] }) }, ticket._id)) })
|
|
6383
6472
|
] }),
|
|
@@ -6387,7 +6476,7 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6387
6476
|
const expanded = expandedExecutionId === execution._id;
|
|
6388
6477
|
const diagnosticCount = execution.errorCount ?? execution.errors?.length ?? (execution.error?.message ? 1 : 0);
|
|
6389
6478
|
return /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: [
|
|
6390
|
-
/* @__PURE__ */ jsxs23(
|
|
6479
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6391
6480
|
/* @__PURE__ */ jsxs23(Box22, { children: [
|
|
6392
6481
|
/* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: execution.title }),
|
|
6393
6482
|
/* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.500", children: [
|
|
@@ -6402,14 +6491,14 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6402
6491
|
] }),
|
|
6403
6492
|
execution.error?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: execution.error.message }) : null
|
|
6404
6493
|
] }),
|
|
6405
|
-
/* @__PURE__ */ jsxs23(
|
|
6494
|
+
/* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
|
|
6406
6495
|
diagnosticCount > 0 ? /* @__PURE__ */ jsxs23(Badge5, { colorPalette: "red", children: [
|
|
6407
6496
|
diagnosticCount,
|
|
6408
6497
|
" erro(s)"
|
|
6409
6498
|
] }) : null,
|
|
6410
6499
|
/* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(execution.status), children: execution.status }),
|
|
6411
6500
|
/* @__PURE__ */ jsx38(
|
|
6412
|
-
|
|
6501
|
+
Button16,
|
|
6413
6502
|
{
|
|
6414
6503
|
size: "xs",
|
|
6415
6504
|
variant: "outline",
|
|
@@ -6428,8 +6517,8 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
6428
6517
|
}
|
|
6429
6518
|
|
|
6430
6519
|
// src/components/CoreIntegrationMappings.tsx
|
|
6431
|
-
import { Badge as Badge6, Box as Box23, Flex as
|
|
6432
|
-
import { useQuery as
|
|
6520
|
+
import { Badge as Badge6, Box as Box23, Flex as Flex16, Heading as Heading13, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
|
|
6521
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
6433
6522
|
import { jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
6434
6523
|
function dateTime2(value2) {
|
|
6435
6524
|
if (!value2) return "sem execu\xE7\xE3o";
|
|
@@ -6438,12 +6527,12 @@ function dateTime2(value2) {
|
|
|
6438
6527
|
}
|
|
6439
6528
|
function CoreIntegrationMappings() {
|
|
6440
6529
|
const { http } = useOonApi();
|
|
6441
|
-
const providers =
|
|
6530
|
+
const providers = useQuery10({
|
|
6442
6531
|
queryKey: ["core-integrations", "providers"],
|
|
6443
6532
|
queryFn: async () => (await http.get("/integrations/providers")).data?.results ?? []
|
|
6444
6533
|
});
|
|
6445
6534
|
const providerKeys = (providers.data ?? []).map((provider) => provider.key).join(",");
|
|
6446
|
-
const summaries =
|
|
6535
|
+
const summaries = useQuery10({
|
|
6447
6536
|
queryKey: ["core-integrations", "mapping-summaries", providerKeys],
|
|
6448
6537
|
enabled: providers.isSuccess && providerKeys.length > 0,
|
|
6449
6538
|
queryFn: async () => Promise.all((providers.data ?? []).map(async (provider) => ({
|
|
@@ -6465,7 +6554,7 @@ function CoreIntegrationMappings() {
|
|
|
6465
6554
|
/* @__PURE__ */ jsx39(Heading13, { size: "sm", children: provider.label }),
|
|
6466
6555
|
/* @__PURE__ */ jsxs24(Box23, { children: [
|
|
6467
6556
|
/* @__PURE__ */ jsx39(Text24, { fontWeight: "semibold", mb: 2, children: "Chamadas Omie" }),
|
|
6468
|
-
/* @__PURE__ */ jsx39(
|
|
6557
|
+
/* @__PURE__ */ jsx39(Flex16, { gap: 2, wrap: "wrap", children: (mappings.calls ?? []).length ? mappings.calls?.map((call) => /* @__PURE__ */ jsxs24(Badge6, { variant: "outline", children: [
|
|
6469
6558
|
call.label || call.key,
|
|
6470
6559
|
" \xB7 ",
|
|
6471
6560
|
call.call || "opera\xE7\xE3o",
|
|
@@ -6476,7 +6565,7 @@ function CoreIntegrationMappings() {
|
|
|
6476
6565
|
/* @__PURE__ */ jsx39(Text24, { fontWeight: "semibold", mb: 2, children: "Listas Omie" }),
|
|
6477
6566
|
/* @__PURE__ */ jsx39(Stack10, { gap: 2, children: (mappings.lists ?? []).length ? mappings.lists?.map((list) => {
|
|
6478
6567
|
const latest = list.executions?.[0];
|
|
6479
|
-
return /* @__PURE__ */ jsx39(Box23, { borderWidth: "1px", borderColor: "gray.100", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs24(
|
|
6568
|
+
return /* @__PURE__ */ jsx39(Box23, { borderWidth: "1px", borderColor: "gray.100", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs24(Flex16, { align: "center", justify: "space-between", gap: 2, wrap: "wrap", children: [
|
|
6480
6569
|
/* @__PURE__ */ jsxs24(Box23, { children: [
|
|
6481
6570
|
/* @__PURE__ */ jsx39(Text24, { fontSize: "sm", fontWeight: "medium", children: list.label || list.key }),
|
|
6482
6571
|
/* @__PURE__ */ jsxs24(Text24, { fontSize: "xs", color: "gray.500", children: [
|
|
@@ -6487,7 +6576,7 @@ function CoreIntegrationMappings() {
|
|
|
6487
6576
|
list.targetModel || "destino declarado"
|
|
6488
6577
|
] })
|
|
6489
6578
|
] }),
|
|
6490
|
-
/* @__PURE__ */ jsxs24(
|
|
6579
|
+
/* @__PURE__ */ jsxs24(Flex16, { gap: 2, wrap: "wrap", children: [
|
|
6491
6580
|
/* @__PURE__ */ jsx39(Badge6, { variant: "outline", children: latest?.status || "n\xE3o executada" }),
|
|
6492
6581
|
/* @__PURE__ */ jsx39(Badge6, { variant: "outline", children: dateTime2(latest?.lastCompletedAt) })
|
|
6493
6582
|
] })
|
|
@@ -6506,12 +6595,683 @@ function CoreIntegrationMappings() {
|
|
|
6506
6595
|
] });
|
|
6507
6596
|
}
|
|
6508
6597
|
|
|
6509
|
-
// src/
|
|
6598
|
+
// src/components/CoreOmieIntegration.tsx
|
|
6599
|
+
import { useEffect as useEffect10, useState as useState15 } from "react";
|
|
6600
|
+
import { Badge as Badge7, Box as Box24, Button as Button17, Flex as Flex17, Heading as Heading14, Input as Input9, Stack as Stack11, Text as Text25 } from "@chakra-ui/react";
|
|
6601
|
+
import { useMutation as useMutation5, useQuery as useQuery11 } from "@tanstack/react-query";
|
|
6510
6602
|
import { jsx as jsx40, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
6603
|
+
function dateTime3(value2) {
|
|
6604
|
+
if (!value2) return "\u2014";
|
|
6605
|
+
const date = new Date(value2);
|
|
6606
|
+
return Number.isNaN(date.getTime()) ? value2 : date.toLocaleString("pt-BR");
|
|
6607
|
+
}
|
|
6608
|
+
function statusPalette2(status) {
|
|
6609
|
+
const normalized2 = String(status || "").toLowerCase();
|
|
6610
|
+
if (normalized2.includes("erro") || normalized2.includes("error") || normalized2.includes("inativo")) return "red";
|
|
6611
|
+
if (normalized2.includes("process") || normalized2.includes("pendente") || normalized2.includes("not-tested")) return "yellow";
|
|
6612
|
+
if (normalized2.includes("conclu\xEDdo") || normalized2.includes("ativo") || normalized2 === "ok") return "green";
|
|
6613
|
+
return "gray";
|
|
6614
|
+
}
|
|
6615
|
+
function integrationErrorMessage2(error) {
|
|
6616
|
+
const candidate = error;
|
|
6617
|
+
const message = candidate?.response?.data?.error?.message || candidate?.response?.data?.message || candidate?.message;
|
|
6618
|
+
return typeof message === "string" && message.trim() ? message : "N\xE3o foi poss\xEDvel concluir a opera\xE7\xE3o.";
|
|
6619
|
+
}
|
|
6620
|
+
function countActive2(values) {
|
|
6621
|
+
return Object.entries(values ?? {}).filter(([status]) => !["Conclu\xEDdo", "Arquivado"].includes(status)).reduce((sum, [, count]) => sum + Number(count || 0), 0);
|
|
6622
|
+
}
|
|
6623
|
+
function absoluteWebhookUrl(path) {
|
|
6624
|
+
if (!path) return "";
|
|
6625
|
+
if (typeof window === "undefined") return path;
|
|
6626
|
+
return new URL(path, window.location.origin).toString();
|
|
6627
|
+
}
|
|
6628
|
+
async function copyText(value2) {
|
|
6629
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
6630
|
+
await navigator.clipboard.writeText(value2);
|
|
6631
|
+
return;
|
|
6632
|
+
}
|
|
6633
|
+
if (typeof document === "undefined") return;
|
|
6634
|
+
const textarea = document.createElement("textarea");
|
|
6635
|
+
textarea.value = value2;
|
|
6636
|
+
textarea.style.position = "fixed";
|
|
6637
|
+
textarea.style.opacity = "0";
|
|
6638
|
+
document.body.appendChild(textarea);
|
|
6639
|
+
textarea.select();
|
|
6640
|
+
document.execCommand("copy");
|
|
6641
|
+
textarea.remove();
|
|
6642
|
+
}
|
|
6643
|
+
function NativeSelect5({
|
|
6644
|
+
value: value2,
|
|
6645
|
+
onChange,
|
|
6646
|
+
children
|
|
6647
|
+
}) {
|
|
6648
|
+
return /* @__PURE__ */ jsx40(
|
|
6649
|
+
"select",
|
|
6650
|
+
{
|
|
6651
|
+
style: {
|
|
6652
|
+
width: "100%",
|
|
6653
|
+
height: "34px",
|
|
6654
|
+
border: "1px solid #e2e8f0",
|
|
6655
|
+
borderRadius: "6px",
|
|
6656
|
+
padding: "0 8px",
|
|
6657
|
+
background: "white"
|
|
6658
|
+
},
|
|
6659
|
+
value: value2,
|
|
6660
|
+
onChange: (event) => onChange(event.currentTarget.value),
|
|
6661
|
+
children
|
|
6662
|
+
}
|
|
6663
|
+
);
|
|
6664
|
+
}
|
|
6665
|
+
function OmieConfigurationTab() {
|
|
6666
|
+
const { http } = useOonApi();
|
|
6667
|
+
const configuration = useQuery11({
|
|
6668
|
+
queryKey: ["core-omie", "configuration"],
|
|
6669
|
+
queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
|
|
6670
|
+
});
|
|
6671
|
+
const [draft, setDraft] = useState15({
|
|
6672
|
+
instanceId: "default",
|
|
6673
|
+
label: "Omie",
|
|
6674
|
+
active: true,
|
|
6675
|
+
environment: "production",
|
|
6676
|
+
baseUrl: "https://app.omie.com.br/api/v1",
|
|
6677
|
+
appKey: "",
|
|
6678
|
+
appSecret: ""
|
|
6679
|
+
});
|
|
6680
|
+
const selected = (configuration.data ?? []).find((item) => item.instanceId === draft.instanceId) ?? configuration.data?.[0];
|
|
6681
|
+
useEffect10(() => {
|
|
6682
|
+
if (!selected) return;
|
|
6683
|
+
setDraft((current) => ({
|
|
6684
|
+
...current,
|
|
6685
|
+
instanceId: selected.instanceId || "default",
|
|
6686
|
+
label: selected.label || "Omie",
|
|
6687
|
+
active: selected.active !== false,
|
|
6688
|
+
environment: selected.environment || "production",
|
|
6689
|
+
baseUrl: selected.baseUrl || "https://app.omie.com.br/api/v1",
|
|
6690
|
+
appKey: "",
|
|
6691
|
+
appSecret: ""
|
|
6692
|
+
}));
|
|
6693
|
+
}, [selected?.instanceId, selected?.updatedAt]);
|
|
6694
|
+
const save = useMutation5({
|
|
6695
|
+
mutationFn: () => http.put(
|
|
6696
|
+
`/integrations/providers/omie/configuration/${draft.instanceId}`,
|
|
6697
|
+
{
|
|
6698
|
+
label: draft.label,
|
|
6699
|
+
active: draft.active,
|
|
6700
|
+
environment: draft.environment,
|
|
6701
|
+
baseUrl: draft.baseUrl,
|
|
6702
|
+
...draft.appKey ? { appKey: draft.appKey } : {},
|
|
6703
|
+
...draft.appSecret ? { appSecret: draft.appSecret } : {}
|
|
6704
|
+
},
|
|
6705
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
6706
|
+
),
|
|
6707
|
+
onSuccess: async () => {
|
|
6708
|
+
setDraft((current) => ({ ...current, appKey: "", appSecret: "" }));
|
|
6709
|
+
await configuration.refetch();
|
|
6710
|
+
}
|
|
6711
|
+
});
|
|
6712
|
+
const testConnection = useMutation5({
|
|
6713
|
+
mutationFn: () => http.post(
|
|
6714
|
+
`/integrations/providers/omie/configuration/${draft.instanceId}/test`,
|
|
6715
|
+
{},
|
|
6716
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
6717
|
+
),
|
|
6718
|
+
onSuccess: () => configuration.refetch()
|
|
6719
|
+
});
|
|
6720
|
+
if (configuration.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
|
|
6721
|
+
if (configuration.error) return /* @__PURE__ */ jsx40(ErrorState, { error: configuration.error });
|
|
6722
|
+
const error = save.error || testConnection.error;
|
|
6723
|
+
return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
|
|
6724
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6725
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Configura\xE7\xF5es" }),
|
|
6726
|
+
/* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. O token do webhook \xE9 gerado e administrado automaticamente." })
|
|
6727
|
+
] }),
|
|
6728
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
|
|
6729
|
+
/* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
|
|
6730
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
|
|
6731
|
+
/* @__PURE__ */ jsx40(
|
|
6732
|
+
NativeSelect5,
|
|
6733
|
+
{
|
|
6734
|
+
value: draft.instanceId,
|
|
6735
|
+
onChange: (instanceId) => setDraft((current) => ({ ...current, instanceId })),
|
|
6736
|
+
children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx40("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId))
|
|
6737
|
+
}
|
|
6738
|
+
)
|
|
6739
|
+
] }),
|
|
6740
|
+
/* @__PURE__ */ jsxs25(Box24, { minW: "240px", flex: "2", children: [
|
|
6741
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Nome" }),
|
|
6742
|
+
/* @__PURE__ */ jsx40(
|
|
6743
|
+
Input9,
|
|
6744
|
+
{
|
|
6745
|
+
size: "sm",
|
|
6746
|
+
value: draft.label,
|
|
6747
|
+
onChange: (event) => setDraft((current) => ({ ...current, label: event.target.value }))
|
|
6748
|
+
}
|
|
6749
|
+
)
|
|
6750
|
+
] }),
|
|
6751
|
+
/* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
|
|
6752
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Ambiente" }),
|
|
6753
|
+
/* @__PURE__ */ jsxs25(
|
|
6754
|
+
NativeSelect5,
|
|
6755
|
+
{
|
|
6756
|
+
value: draft.environment,
|
|
6757
|
+
onChange: (environment) => setDraft((current) => ({ ...current, environment })),
|
|
6758
|
+
children: [
|
|
6759
|
+
/* @__PURE__ */ jsx40("option", { value: "production", children: "Produ\xE7\xE3o" }),
|
|
6760
|
+
/* @__PURE__ */ jsx40("option", { value: "homologation", children: "Homologa\xE7\xE3o" })
|
|
6761
|
+
]
|
|
6762
|
+
}
|
|
6763
|
+
)
|
|
6764
|
+
] })
|
|
6765
|
+
] }),
|
|
6766
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6767
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL base" }),
|
|
6768
|
+
/* @__PURE__ */ jsx40(
|
|
6769
|
+
Input9,
|
|
6770
|
+
{
|
|
6771
|
+
size: "sm",
|
|
6772
|
+
value: draft.baseUrl,
|
|
6773
|
+
onChange: (event) => setDraft((current) => ({ ...current, baseUrl: event.target.value }))
|
|
6774
|
+
}
|
|
6775
|
+
)
|
|
6776
|
+
] }),
|
|
6777
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
|
|
6778
|
+
/* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
|
|
6779
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: [
|
|
6780
|
+
"App Key ",
|
|
6781
|
+
selected?.appKeyMasked ? `(${selected.appKeyMasked})` : ""
|
|
6782
|
+
] }),
|
|
6783
|
+
/* @__PURE__ */ jsx40(
|
|
6784
|
+
Input9,
|
|
6785
|
+
{
|
|
6786
|
+
size: "sm",
|
|
6787
|
+
type: "password",
|
|
6788
|
+
value: draft.appKey,
|
|
6789
|
+
onChange: (event) => setDraft((current) => ({ ...current, appKey: event.target.value })),
|
|
6790
|
+
placeholder: selected?.credentialsConfigured ? "Manter valor atual" : "Informe a App Key"
|
|
6791
|
+
}
|
|
6792
|
+
)
|
|
6793
|
+
] }),
|
|
6794
|
+
/* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
|
|
6795
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "App Secret" }),
|
|
6796
|
+
/* @__PURE__ */ jsx40(
|
|
6797
|
+
Input9,
|
|
6798
|
+
{
|
|
6799
|
+
size: "sm",
|
|
6800
|
+
type: "password",
|
|
6801
|
+
value: draft.appSecret,
|
|
6802
|
+
onChange: (event) => setDraft((current) => ({ ...current, appSecret: event.target.value })),
|
|
6803
|
+
placeholder: selected?.credentialsConfigured ? "Manter valor atual" : "Informe o App Secret"
|
|
6804
|
+
}
|
|
6805
|
+
)
|
|
6806
|
+
] })
|
|
6807
|
+
] }),
|
|
6808
|
+
/* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6809
|
+
/* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
|
|
6810
|
+
/* @__PURE__ */ jsxs25("label", { children: [
|
|
6811
|
+
/* @__PURE__ */ jsx40(
|
|
6812
|
+
"input",
|
|
6813
|
+
{
|
|
6814
|
+
type: "checkbox",
|
|
6815
|
+
checked: draft.active,
|
|
6816
|
+
onChange: (event) => setDraft((current) => ({ ...current, active: event.target.checked }))
|
|
6817
|
+
}
|
|
6818
|
+
),
|
|
6819
|
+
" ",
|
|
6820
|
+
"Integra\xE7\xE3o ativa"
|
|
6821
|
+
] }),
|
|
6822
|
+
/* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(selected?.connectionStatus), children: [
|
|
6823
|
+
"Conex\xE3o: ",
|
|
6824
|
+
selected?.connectionStatus ?? "n\xE3o testada"
|
|
6825
|
+
] }),
|
|
6826
|
+
/* @__PURE__ */ jsxs25(Badge7, { colorPalette: selected?.webhookConfigured ? "green" : "yellow", children: [
|
|
6827
|
+
"Webhook: ",
|
|
6828
|
+
selected?.webhookConfigured ? "configurado" : "ser\xE1 gerado"
|
|
6829
|
+
] }),
|
|
6830
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", children: [
|
|
6831
|
+
"\xDAltimo teste: ",
|
|
6832
|
+
dateTime3(selected?.lastConnectionTestAt)
|
|
6833
|
+
] })
|
|
6834
|
+
] }),
|
|
6835
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
|
|
6836
|
+
/* @__PURE__ */ jsx40(
|
|
6837
|
+
Button17,
|
|
6838
|
+
{
|
|
6839
|
+
size: "sm",
|
|
6840
|
+
variant: "outline",
|
|
6841
|
+
loading: testConnection.isPending,
|
|
6842
|
+
onClick: () => testConnection.mutate(),
|
|
6843
|
+
children: "Testar conex\xE3o"
|
|
6844
|
+
}
|
|
6845
|
+
),
|
|
6846
|
+
/* @__PURE__ */ jsx40(Button17, { size: "sm", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xF5es" })
|
|
6847
|
+
] })
|
|
6848
|
+
] }),
|
|
6849
|
+
selected?.lastConnectionError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: selected.lastConnectionError }) : null,
|
|
6850
|
+
error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
|
|
6851
|
+
] });
|
|
6852
|
+
}
|
|
6853
|
+
function OmieSynchronizationTab() {
|
|
6854
|
+
const { http } = useOonApi();
|
|
6855
|
+
const health = useQuery11({
|
|
6856
|
+
queryKey: ["core-omie", "health"],
|
|
6857
|
+
queryFn: async () => {
|
|
6858
|
+
const providers = (await http.get("/integrations/health")).data?.results ?? [];
|
|
6859
|
+
return providers.find((provider2) => provider2.key === "omie") ?? null;
|
|
6860
|
+
}
|
|
6861
|
+
});
|
|
6862
|
+
const mappings = useQuery11({
|
|
6863
|
+
queryKey: ["core-omie", "mappings"],
|
|
6864
|
+
queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
|
|
6865
|
+
});
|
|
6866
|
+
const queue = useQuery11({
|
|
6867
|
+
queryKey: ["core-omie", "queue"],
|
|
6868
|
+
queryFn: async () => (await http.get("/integrations/queue", {
|
|
6869
|
+
params: { provider: "omie", limit: 20 }
|
|
6870
|
+
})).data?.results ?? []
|
|
6871
|
+
});
|
|
6872
|
+
const refresh = () => Promise.all([health.refetch(), mappings.refetch(), queue.refetch()]);
|
|
6873
|
+
const syncAll = useMutation5({
|
|
6874
|
+
mutationFn: () => http.post(
|
|
6875
|
+
"/integrations/providers/omie/sync-all",
|
|
6876
|
+
{},
|
|
6877
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
6878
|
+
),
|
|
6879
|
+
onSuccess: refresh
|
|
6880
|
+
});
|
|
6881
|
+
const syncResource = useMutation5({
|
|
6882
|
+
mutationFn: (resource) => http.post(
|
|
6883
|
+
`/integrations/providers/omie/resources/${resource}/sync`,
|
|
6884
|
+
{},
|
|
6885
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
6886
|
+
),
|
|
6887
|
+
onSuccess: refresh
|
|
6888
|
+
});
|
|
6889
|
+
const process = useMutation5({
|
|
6890
|
+
mutationFn: () => http.post(
|
|
6891
|
+
"/integrations/actions/process-active",
|
|
6892
|
+
{ provider: "omie" },
|
|
6893
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
6894
|
+
),
|
|
6895
|
+
onSuccess: refresh
|
|
6896
|
+
});
|
|
6897
|
+
if (health.isLoading || mappings.isLoading || queue.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
|
|
6898
|
+
const error = health.error || mappings.error || queue.error || syncAll.error || syncResource.error || process.error;
|
|
6899
|
+
if ((health.error || mappings.error || queue.error) && !health.data) return /* @__PURE__ */ jsx40(ErrorState, { error });
|
|
6900
|
+
const provider = health.data;
|
|
6901
|
+
return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
|
|
6902
|
+
/* @__PURE__ */ jsxs25(Flex17, { align: "start", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6903
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6904
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Sincroniza\xE7\xE3o" }),
|
|
6905
|
+
/* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execute listas declaradas e acompanhe o processamento da fila Omie." })
|
|
6906
|
+
] }),
|
|
6907
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
|
|
6908
|
+
/* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" }),
|
|
6909
|
+
/* @__PURE__ */ jsx40(Button17, { size: "sm", loading: syncAll.isPending, onClick: () => syncAll.mutate(), children: "Sincronizar tudo" })
|
|
6910
|
+
] })
|
|
6911
|
+
] }),
|
|
6912
|
+
provider ? /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: [
|
|
6913
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", mb: 3, children: [
|
|
6914
|
+
/* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(provider.status), children: provider.status || "\u2014" }),
|
|
6915
|
+
/* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.queue) ? "yellow" : "green", children: [
|
|
6916
|
+
"Fila ativa: ",
|
|
6917
|
+
countActive2(provider.queue)
|
|
6918
|
+
] }),
|
|
6919
|
+
/* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.inbox) ? "yellow" : "green", children: [
|
|
6920
|
+
"Eventos ativos: ",
|
|
6921
|
+
countActive2(provider.inbox)
|
|
6922
|
+
] }),
|
|
6923
|
+
/* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(provider.lastExecution?.status), children: [
|
|
6924
|
+
"\xDAltima execu\xE7\xE3o: ",
|
|
6925
|
+
provider.lastExecution?.status || "sem hist\xF3rico"
|
|
6926
|
+
] })
|
|
6927
|
+
] }),
|
|
6928
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", mb: 3, children: [
|
|
6929
|
+
"Pend\xEAncia mais antiga: ",
|
|
6930
|
+
dateTime3(provider.oldestPendingAt)
|
|
6931
|
+
] }),
|
|
6932
|
+
/* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx40(
|
|
6933
|
+
Button17,
|
|
6934
|
+
{
|
|
6935
|
+
size: "sm",
|
|
6936
|
+
variant: "outline",
|
|
6937
|
+
loading: syncResource.isPending,
|
|
6938
|
+
onClick: () => syncResource.mutate(resource.key),
|
|
6939
|
+
children: resource.label
|
|
6940
|
+
},
|
|
6941
|
+
resource.key
|
|
6942
|
+
)) })
|
|
6943
|
+
] }) : /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Provider Omie n\xE3o registrado." }),
|
|
6944
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6945
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Listas declaradas" }),
|
|
6946
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (mappings.data?.lists ?? []).map((list) => {
|
|
6947
|
+
const latest = list.executions?.[0];
|
|
6948
|
+
return /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6949
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6950
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: list.label || list.key }),
|
|
6951
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
|
|
6952
|
+
list.mode || "modo padr\xE3o",
|
|
6953
|
+
" \xB7 ",
|
|
6954
|
+
list.direction || "dire\xE7\xE3o padr\xE3o",
|
|
6955
|
+
" \xB7 ",
|
|
6956
|
+
list.targetModel || "destino declarado"
|
|
6957
|
+
] })
|
|
6958
|
+
] }),
|
|
6959
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", children: [
|
|
6960
|
+
/* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(latest?.status), children: latest?.status || "n\xE3o executada" }),
|
|
6961
|
+
/* @__PURE__ */ jsx40(Badge7, { variant: "outline", children: dateTime3(latest?.lastCompletedAt) })
|
|
6962
|
+
] })
|
|
6963
|
+
] }) }, list.key);
|
|
6964
|
+
}) })
|
|
6965
|
+
] }),
|
|
6966
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6967
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Fila recente" }),
|
|
6968
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (queue.data ?? []).length ? queue.data?.map((ticket) => /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
6969
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
6970
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: ticket.handler }),
|
|
6971
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
|
|
6972
|
+
ticket.resource || "sem recurso",
|
|
6973
|
+
" \xB7 tentativas ",
|
|
6974
|
+
ticket.attempts ?? 0,
|
|
6975
|
+
" \xB7 pr\xF3xima ",
|
|
6976
|
+
dateTime3(ticket.nextAttemptAt)
|
|
6977
|
+
] }),
|
|
6978
|
+
ticket.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
|
|
6979
|
+
] }),
|
|
6980
|
+
/* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticket.status), children: ticket.status })
|
|
6981
|
+
] }) }, ticket._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma pend\xEAncia Omie." }) })
|
|
6982
|
+
] }),
|
|
6983
|
+
error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
|
|
6984
|
+
] });
|
|
6985
|
+
}
|
|
6986
|
+
function OmieWebhooksTab() {
|
|
6987
|
+
const { http } = useOonApi();
|
|
6988
|
+
const [instanceId, setInstanceId] = useState15("default");
|
|
6989
|
+
const [copied, setCopied] = useState15(false);
|
|
6990
|
+
const configuration = useQuery11({
|
|
6991
|
+
queryKey: ["core-omie", "configuration"],
|
|
6992
|
+
queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
|
|
6993
|
+
});
|
|
6994
|
+
const access = useQuery11({
|
|
6995
|
+
queryKey: ["core-omie", "webhook-access", instanceId],
|
|
6996
|
+
enabled: Boolean(instanceId),
|
|
6997
|
+
queryFn: async () => (await http.get(
|
|
6998
|
+
`/integrations/providers/omie/configuration/${instanceId}/webhook`
|
|
6999
|
+
)).data
|
|
7000
|
+
});
|
|
7001
|
+
const mappings = useQuery11({
|
|
7002
|
+
queryKey: ["core-omie", "mappings"],
|
|
7003
|
+
queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
|
|
7004
|
+
});
|
|
7005
|
+
const events = useQuery11({
|
|
7006
|
+
queryKey: ["core-omie", "events"],
|
|
7007
|
+
queryFn: async () => (await http.get("/integrations/events", {
|
|
7008
|
+
params: { provider: "omie", limit: 20 }
|
|
7009
|
+
})).data?.results ?? []
|
|
7010
|
+
});
|
|
7011
|
+
const rotate = useMutation5({
|
|
7012
|
+
mutationFn: () => http.post(
|
|
7013
|
+
`/integrations/providers/omie/configuration/${instanceId}/webhook/rotate`,
|
|
7014
|
+
{},
|
|
7015
|
+
{ headers: { "x-oon-origin": "integration" } }
|
|
7016
|
+
),
|
|
7017
|
+
onSuccess: async () => {
|
|
7018
|
+
setCopied(false);
|
|
7019
|
+
await Promise.all([access.refetch(), configuration.refetch()]);
|
|
7020
|
+
}
|
|
7021
|
+
});
|
|
7022
|
+
useEffect10(() => {
|
|
7023
|
+
const first = configuration.data?.[0]?.instanceId;
|
|
7024
|
+
if (first && !configuration.data?.some((item) => item.instanceId === instanceId)) setInstanceId(first);
|
|
7025
|
+
}, [configuration.data, instanceId]);
|
|
7026
|
+
if (configuration.isLoading || mappings.isLoading || events.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
|
|
7027
|
+
const blockingError = configuration.error || mappings.error || events.error;
|
|
7028
|
+
if (blockingError) return /* @__PURE__ */ jsx40(ErrorState, { error: blockingError });
|
|
7029
|
+
const url = absoluteWebhookUrl(access.data?.webhookPath);
|
|
7030
|
+
const operationError = access.error || rotate.error;
|
|
7031
|
+
return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
|
|
7032
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7033
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Webhooks e gatilhos" }),
|
|
7034
|
+
/* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Copie a URL completa para o cadastro de webhook no Omie. O token \xE9 gerado automaticamente e pode ser rotacionado." })
|
|
7035
|
+
] }),
|
|
7036
|
+
/* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: /* @__PURE__ */ jsxs25(Stack11, { gap: 3, children: [
|
|
7037
|
+
/* @__PURE__ */ jsxs25(Box24, { maxW: "360px", children: [
|
|
7038
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
|
|
7039
|
+
/* @__PURE__ */ jsx40(NativeSelect5, { value: instanceId, onChange: setInstanceId, children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx40("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId)) })
|
|
7040
|
+
] }),
|
|
7041
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7042
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL do webhook" }),
|
|
7043
|
+
/* @__PURE__ */ jsxs25(Flex17, { gap: 2, align: "center", wrap: "wrap", children: [
|
|
7044
|
+
/* @__PURE__ */ jsx40(
|
|
7045
|
+
Input9,
|
|
7046
|
+
{
|
|
7047
|
+
size: "sm",
|
|
7048
|
+
value: url,
|
|
7049
|
+
readOnly: true,
|
|
7050
|
+
minW: "320px",
|
|
7051
|
+
flex: "1",
|
|
7052
|
+
placeholder: access.isLoading ? "Gerando URL segura\u2026" : "URL indispon\xEDvel"
|
|
7053
|
+
}
|
|
7054
|
+
),
|
|
7055
|
+
/* @__PURE__ */ jsx40(
|
|
7056
|
+
Button17,
|
|
7057
|
+
{
|
|
7058
|
+
size: "sm",
|
|
7059
|
+
variant: "outline",
|
|
7060
|
+
disabled: !url,
|
|
7061
|
+
onClick: async () => {
|
|
7062
|
+
await copyText(url);
|
|
7063
|
+
setCopied(true);
|
|
7064
|
+
},
|
|
7065
|
+
children: copied ? "Link copiado" : "Copiar link"
|
|
7066
|
+
}
|
|
7067
|
+
),
|
|
7068
|
+
/* @__PURE__ */ jsx40(
|
|
7069
|
+
Button17,
|
|
7070
|
+
{
|
|
7071
|
+
size: "sm",
|
|
7072
|
+
colorPalette: "red",
|
|
7073
|
+
variant: "outline",
|
|
7074
|
+
loading: rotate.isPending,
|
|
7075
|
+
onClick: () => {
|
|
7076
|
+
if (typeof window === "undefined" || window.confirm(
|
|
7077
|
+
"Gerar um novo token? A URL anterior deixar\xE1 de receber eventos."
|
|
7078
|
+
)) rotate.mutate();
|
|
7079
|
+
},
|
|
7080
|
+
children: "Gerar novo token"
|
|
7081
|
+
}
|
|
7082
|
+
)
|
|
7083
|
+
] }),
|
|
7084
|
+
/* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mt: 2, children: "A rota\xE7\xE3o invalida imediatamente a URL anterior. Atualize o cadastro no Omie ap\xF3s gerar um novo token." })
|
|
7085
|
+
] })
|
|
7086
|
+
] }) }),
|
|
7087
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7088
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Gatilhos declarados" }),
|
|
7089
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (mappings.data?.webhooks ?? []).length ? mappings.data?.webhooks?.map((webhook) => /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
|
|
7090
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: webhook.eventType }),
|
|
7091
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
|
|
7092
|
+
webhook.resource || "recurso gen\xE9rico",
|
|
7093
|
+
" \u2192 ",
|
|
7094
|
+
(webhook.actions ?? []).map((action) => action.handler).filter(Boolean).join(", ") || "sem a\xE7\xE3o declarada"
|
|
7095
|
+
] })
|
|
7096
|
+
] }, `${webhook.eventType}:${webhook.resource || ""}`)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum gatilho declarado pela Central." }) })
|
|
7097
|
+
] }),
|
|
7098
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7099
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Eventos recebidos" }),
|
|
7100
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (events.data ?? []).length ? events.data?.map((event) => /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
7101
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7102
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: event.eventType || "Evento Omie" }),
|
|
7103
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
|
|
7104
|
+
event.resource || "sem recurso",
|
|
7105
|
+
" \xB7 recebido em ",
|
|
7106
|
+
dateTime3(event.receivedAt),
|
|
7107
|
+
" \xB7 tentativas ",
|
|
7108
|
+
event.attempts ?? 0
|
|
7109
|
+
] }),
|
|
7110
|
+
event.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: event.lastError.message }) : null
|
|
7111
|
+
] }),
|
|
7112
|
+
/* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(event.status), children: event.status })
|
|
7113
|
+
] }) }, event._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum webhook recebido." }) })
|
|
7114
|
+
] }),
|
|
7115
|
+
operationError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(operationError) }) : null
|
|
7116
|
+
] });
|
|
7117
|
+
}
|
|
7118
|
+
function diagnosticMessage2(value2) {
|
|
7119
|
+
return value2.error?.message || value2.message || "Erro sem mensagem registrada.";
|
|
7120
|
+
}
|
|
7121
|
+
function OmieHistoryTab() {
|
|
7122
|
+
const { http } = useOonApi();
|
|
7123
|
+
const [expandedId, setExpandedId] = useState15(null);
|
|
7124
|
+
const history = useQuery11({
|
|
7125
|
+
queryKey: ["core-omie", "history"],
|
|
7126
|
+
queryFn: async () => (await http.get("/integrations/history", {
|
|
7127
|
+
params: { provider: "omie", limit: 30 }
|
|
7128
|
+
})).data?.results ?? []
|
|
7129
|
+
});
|
|
7130
|
+
if (history.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
|
|
7131
|
+
if (history.error) return /* @__PURE__ */ jsx40(ErrorState, { error: history.error });
|
|
7132
|
+
return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
|
|
7133
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7134
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Hist\xF3rico" }),
|
|
7135
|
+
/* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execu\xE7\xF5es, erros por registro e diagn\xF3stico t\xE9cnico sanitizado." })
|
|
7136
|
+
] }),
|
|
7137
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (history.data ?? []).length ? history.data?.map((execution) => {
|
|
7138
|
+
const expanded = expandedId === execution._id;
|
|
7139
|
+
const diagnostics = [...execution.errors ?? []];
|
|
7140
|
+
if (execution.error?.message && !diagnostics.some((item) => diagnosticMessage2(item) === execution.error?.message)) {
|
|
7141
|
+
diagnostics.push({ error: execution.error });
|
|
7142
|
+
}
|
|
7143
|
+
return /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
|
|
7144
|
+
/* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
|
|
7145
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7146
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: execution.title }),
|
|
7147
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
|
|
7148
|
+
execution.resource || "sem recurso",
|
|
7149
|
+
" \xB7 ",
|
|
7150
|
+
dateTime3(execution.startedAt),
|
|
7151
|
+
" \xB7 ",
|
|
7152
|
+
execution.durationMs ?? 0,
|
|
7153
|
+
" ms"
|
|
7154
|
+
] })
|
|
7155
|
+
] }),
|
|
7156
|
+
/* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
|
|
7157
|
+
(execution.errorCount ?? diagnostics.length) > 0 ? /* @__PURE__ */ jsxs25(Badge7, { colorPalette: "red", children: [
|
|
7158
|
+
execution.errorCount ?? diagnostics.length,
|
|
7159
|
+
" erro(s)"
|
|
7160
|
+
] }) : null,
|
|
7161
|
+
/* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(execution.status), children: execution.status }),
|
|
7162
|
+
/* @__PURE__ */ jsx40(
|
|
7163
|
+
Button17,
|
|
7164
|
+
{
|
|
7165
|
+
size: "sm",
|
|
7166
|
+
variant: "outline",
|
|
7167
|
+
"aria-expanded": expanded,
|
|
7168
|
+
onClick: () => setExpandedId((current) => current === execution._id ? null : execution._id),
|
|
7169
|
+
children: expanded ? "Ocultar detalhes" : "Ver detalhes"
|
|
7170
|
+
}
|
|
7171
|
+
)
|
|
7172
|
+
] })
|
|
7173
|
+
] }),
|
|
7174
|
+
expanded ? /* @__PURE__ */ jsxs25(Stack11, { gap: 3, mt: 3, pt: 3, borderTopWidth: "1px", children: [
|
|
7175
|
+
execution.summary && Object.keys(execution.summary).length ? /* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7176
|
+
/* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: "Resumo" }),
|
|
7177
|
+
/* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: Object.entries(execution.summary).map(([key, value2]) => /* @__PURE__ */ jsxs25(Badge7, { variant: "outline", children: [
|
|
7178
|
+
key,
|
|
7179
|
+
": ",
|
|
7180
|
+
String(value2 ?? "\u2014")
|
|
7181
|
+
] }, key)) })
|
|
7182
|
+
] }) : null,
|
|
7183
|
+
diagnostics.length ? /* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7184
|
+
/* @__PURE__ */ jsxs25(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: [
|
|
7185
|
+
"Erros por registro",
|
|
7186
|
+
execution.errorsLimited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
|
|
7187
|
+
] }),
|
|
7188
|
+
/* @__PURE__ */ jsx40(Stack11, { gap: 2, children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs25(
|
|
7189
|
+
Box24,
|
|
7190
|
+
{
|
|
7191
|
+
borderWidth: "1px",
|
|
7192
|
+
borderColor: "red.100",
|
|
7193
|
+
borderRadius: "md",
|
|
7194
|
+
bg: "red.50",
|
|
7195
|
+
p: 3,
|
|
7196
|
+
children: [
|
|
7197
|
+
/* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.600", children: [
|
|
7198
|
+
"Registro ",
|
|
7199
|
+
diagnostic.index !== void 0 ? diagnostic.index + 1 : index + 1,
|
|
7200
|
+
diagnostic.externalKey !== void 0 ? ` \xB7 chave ${String(diagnostic.externalKey)}` : "",
|
|
7201
|
+
diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode ? ` \xB7 c\xF3digo ${String(diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode)}` : ""
|
|
7202
|
+
] }),
|
|
7203
|
+
/* @__PURE__ */ jsx40(Text25, { color: "red.700", children: diagnosticMessage2(diagnostic) })
|
|
7204
|
+
]
|
|
7205
|
+
},
|
|
7206
|
+
`${diagnostic.index ?? index}:${diagnosticMessage2(diagnostic)}`
|
|
7207
|
+
)) })
|
|
7208
|
+
] }) : null,
|
|
7209
|
+
[
|
|
7210
|
+
["Itens processados", execution.items, execution.itemCount, execution.itemsLimited],
|
|
7211
|
+
["Chamadas sanitizadas", execution.requests, execution.requestCount, execution.requestsLimited],
|
|
7212
|
+
["Metadados", execution.metadata, void 0, false]
|
|
7213
|
+
].map(([label, value2, count, limited]) => value2 ? /* @__PURE__ */ jsxs25("details", { children: [
|
|
7214
|
+
/* @__PURE__ */ jsxs25("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: [
|
|
7215
|
+
String(label),
|
|
7216
|
+
typeof count === "number" ? ` (${count})` : "",
|
|
7217
|
+
limited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
|
|
7218
|
+
] }),
|
|
7219
|
+
/* @__PURE__ */ jsx40(
|
|
7220
|
+
Box24,
|
|
7221
|
+
{
|
|
7222
|
+
as: "pre",
|
|
7223
|
+
mt: 2,
|
|
7224
|
+
p: 3,
|
|
7225
|
+
borderRadius: "md",
|
|
7226
|
+
bg: "gray.50",
|
|
7227
|
+
overflowX: "auto",
|
|
7228
|
+
whiteSpace: "pre-wrap",
|
|
7229
|
+
fontSize: "xs",
|
|
7230
|
+
children: JSON.stringify(value2, null, 2)
|
|
7231
|
+
}
|
|
7232
|
+
)
|
|
7233
|
+
] }, String(label)) : null)
|
|
7234
|
+
] }) : null
|
|
7235
|
+
] }, execution._id);
|
|
7236
|
+
}) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o Omie registrada." }) })
|
|
7237
|
+
] });
|
|
7238
|
+
}
|
|
7239
|
+
var TABS = [
|
|
7240
|
+
{ id: "configuration", label: "Configura\xE7\xF5es" },
|
|
7241
|
+
{ id: "synchronization", label: "Sincroniza\xE7\xE3o" },
|
|
7242
|
+
{ id: "webhooks", label: "Webhooks/Gatilhos" },
|
|
7243
|
+
{ id: "history", label: "Hist\xF3rico" }
|
|
7244
|
+
];
|
|
7245
|
+
function CoreOmieIntegration() {
|
|
7246
|
+
const [tab, setTab] = useState15("configuration");
|
|
7247
|
+
return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
|
|
7248
|
+
/* @__PURE__ */ jsxs25(Box24, { children: [
|
|
7249
|
+
/* @__PURE__ */ jsx40(Heading14, { size: "lg", children: "Integra\xE7\xE3o Omie" }),
|
|
7250
|
+
/* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Configure credenciais, sincroniza\xE7\xF5es, webhooks, gatilhos e diagn\xF3sticos da inst\xE2ncia Omie." })
|
|
7251
|
+
] }),
|
|
7252
|
+
/* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: TABS.map((item) => /* @__PURE__ */ jsx40(
|
|
7253
|
+
Button17,
|
|
7254
|
+
{
|
|
7255
|
+
size: "sm",
|
|
7256
|
+
variant: tab === item.id ? "solid" : "ghost",
|
|
7257
|
+
onClick: () => setTab(item.id),
|
|
7258
|
+
children: item.label
|
|
7259
|
+
},
|
|
7260
|
+
item.id
|
|
7261
|
+
)) }),
|
|
7262
|
+
tab === "configuration" ? /* @__PURE__ */ jsx40(OmieConfigurationTab, {}) : null,
|
|
7263
|
+
tab === "synchronization" ? /* @__PURE__ */ jsx40(OmieSynchronizationTab, {}) : null,
|
|
7264
|
+
tab === "webhooks" ? /* @__PURE__ */ jsx40(OmieWebhooksTab, {}) : null,
|
|
7265
|
+
tab === "history" ? /* @__PURE__ */ jsx40(OmieHistoryTab, {}) : null
|
|
7266
|
+
] });
|
|
7267
|
+
}
|
|
7268
|
+
|
|
7269
|
+
// src/modules/integrations.tsx
|
|
7270
|
+
import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6511
7271
|
function CoreIntegrationPage() {
|
|
6512
|
-
return /* @__PURE__ */
|
|
6513
|
-
/* @__PURE__ */
|
|
6514
|
-
/* @__PURE__ */
|
|
7272
|
+
return /* @__PURE__ */ jsxs26(Stack12, { gap: 8, children: [
|
|
7273
|
+
/* @__PURE__ */ jsx41(CoreIntegration, {}),
|
|
7274
|
+
/* @__PURE__ */ jsx41(CoreIntegrationMappings, {})
|
|
6515
7275
|
] });
|
|
6516
7276
|
}
|
|
6517
7277
|
function createIntegrationModule() {
|
|
@@ -6521,19 +7281,16 @@ function createIntegrationModule() {
|
|
|
6521
7281
|
routes: [
|
|
6522
7282
|
{
|
|
6523
7283
|
path: "/integracoes",
|
|
6524
|
-
element: /* @__PURE__ */
|
|
7284
|
+
element: /* @__PURE__ */ jsx41(CoreIntegrationPage, {}),
|
|
6525
7285
|
capabilities: ["core.integrations"]
|
|
6526
|
-
}
|
|
6527
|
-
],
|
|
6528
|
-
menu: [
|
|
7286
|
+
},
|
|
6529
7287
|
{
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
order: 800,
|
|
6534
|
-
capabilities: ["core.integrations"]
|
|
7288
|
+
path: "/configuracoes/integracao-omie",
|
|
7289
|
+
element: /* @__PURE__ */ jsx41(CoreOmieIntegration, {}),
|
|
7290
|
+
capabilities: ["core.integrations", "core.integrations.omie"]
|
|
6535
7291
|
}
|
|
6536
|
-
]
|
|
7292
|
+
],
|
|
7293
|
+
menu: []
|
|
6537
7294
|
};
|
|
6538
7295
|
}
|
|
6539
7296
|
|
|
@@ -6583,36 +7340,36 @@ function defineOonModule(mod) {
|
|
|
6583
7340
|
}
|
|
6584
7341
|
|
|
6585
7342
|
// src/components/CoreCurrency.tsx
|
|
6586
|
-
import { Button as
|
|
6587
|
-
import { useMutation as
|
|
6588
|
-
import { jsx as
|
|
7343
|
+
import { Button as Button18, Flex as Flex18, Heading as Heading15, Stack as Stack13, Text as Text26 } from "@chakra-ui/react";
|
|
7344
|
+
import { useMutation as useMutation6, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
7345
|
+
import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6589
7346
|
function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/moedas", columns }) {
|
|
6590
7347
|
const { http } = useOonApi();
|
|
6591
7348
|
const queryClient = useQueryClient5();
|
|
6592
|
-
const updateRates =
|
|
7349
|
+
const updateRates = useMutation6({
|
|
6593
7350
|
mutationFn: () => http.post(`${endpoint}/actions/update-rates`, {}, { headers: { "x-oon-origin": "integration" } }),
|
|
6594
7351
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["oon", "list", endpoint] })
|
|
6595
7352
|
});
|
|
6596
|
-
return /* @__PURE__ */
|
|
6597
|
-
/* @__PURE__ */
|
|
6598
|
-
/* @__PURE__ */
|
|
6599
|
-
/* @__PURE__ */
|
|
7353
|
+
return /* @__PURE__ */ jsxs27(Stack13, { gap: 6, children: [
|
|
7354
|
+
/* @__PURE__ */ jsxs27(Flex18, { align: "center", justify: "space-between", children: [
|
|
7355
|
+
/* @__PURE__ */ jsx42(Heading15, { size: "lg", children: label }),
|
|
7356
|
+
/* @__PURE__ */ jsx42(Button18, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
|
|
6600
7357
|
] }),
|
|
6601
|
-
updateRates.isError ? /* @__PURE__ */
|
|
6602
|
-
/* @__PURE__ */
|
|
7358
|
+
updateRates.isError ? /* @__PURE__ */ jsx42(Text26, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
|
|
7359
|
+
/* @__PURE__ */ jsx42(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
|
|
6603
7360
|
] });
|
|
6604
7361
|
}
|
|
6605
7362
|
|
|
6606
7363
|
// src/components/CoreAssistant.tsx
|
|
6607
|
-
import { useState as
|
|
6608
|
-
import { Box as
|
|
6609
|
-
import { useMutation as
|
|
6610
|
-
import { jsx as
|
|
7364
|
+
import { useState as useState16 } from "react";
|
|
7365
|
+
import { Box as Box25, Button as Button19, Flex as Flex19, Heading as Heading16, Input as Input10, Stack as Stack14, Text as Text27 } from "@chakra-ui/react";
|
|
7366
|
+
import { useMutation as useMutation7 } from "@tanstack/react-query";
|
|
7367
|
+
import { jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
6611
7368
|
function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint = "/assistant-runs" }) {
|
|
6612
7369
|
const { http } = useOonApi();
|
|
6613
|
-
const [messages, setMessages] =
|
|
6614
|
-
const [input, setInput] =
|
|
6615
|
-
const ask =
|
|
7370
|
+
const [messages, setMessages] = useState16([]);
|
|
7371
|
+
const [input, setInput] = useState16("");
|
|
7372
|
+
const ask = useMutation7({
|
|
6616
7373
|
mutationFn: async (message) => {
|
|
6617
7374
|
const { data } = await http.post(
|
|
6618
7375
|
endpoint,
|
|
@@ -6636,11 +7393,11 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
6636
7393
|
setInput("");
|
|
6637
7394
|
ask.mutate(text);
|
|
6638
7395
|
};
|
|
6639
|
-
return /* @__PURE__ */
|
|
6640
|
-
/* @__PURE__ */
|
|
6641
|
-
/* @__PURE__ */
|
|
6642
|
-
messages.length === 0 ? /* @__PURE__ */
|
|
6643
|
-
|
|
7396
|
+
return /* @__PURE__ */ jsxs28(Stack14, { gap: 4, maxW: "560px", children: [
|
|
7397
|
+
/* @__PURE__ */ jsx43(Heading16, { size: "md", children: label }),
|
|
7398
|
+
/* @__PURE__ */ jsx43(Box25, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs28(Stack14, { gap: 3, children: [
|
|
7399
|
+
messages.length === 0 ? /* @__PURE__ */ jsx43(Text27, { color: "gray.400", fontSize: "sm", children: "Fa\xE7a uma pergunta ao assistente." }) : messages.map((m, idx) => /* @__PURE__ */ jsx43(Flex19, { justify: m.role === "user" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx43(
|
|
7400
|
+
Box25,
|
|
6644
7401
|
{
|
|
6645
7402
|
bg: m.role === "user" ? "brand.500" : "gray.100",
|
|
6646
7403
|
color: m.role === "user" ? "white" : "gray.800",
|
|
@@ -6652,12 +7409,12 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
6652
7409
|
children: m.content
|
|
6653
7410
|
}
|
|
6654
7411
|
) }, idx)),
|
|
6655
|
-
ask.isPending ? /* @__PURE__ */
|
|
6656
|
-
ask.isError ? /* @__PURE__ */
|
|
7412
|
+
ask.isPending ? /* @__PURE__ */ jsx43(Text27, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
|
|
7413
|
+
ask.isError ? /* @__PURE__ */ jsx43(Text27, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
|
|
6657
7414
|
] }) }),
|
|
6658
|
-
/* @__PURE__ */
|
|
6659
|
-
/* @__PURE__ */
|
|
6660
|
-
|
|
7415
|
+
/* @__PURE__ */ jsxs28(Flex19, { gap: 2, children: [
|
|
7416
|
+
/* @__PURE__ */ jsx43(
|
|
7417
|
+
Input10,
|
|
6661
7418
|
{
|
|
6662
7419
|
size: "sm",
|
|
6663
7420
|
value: input,
|
|
@@ -6668,7 +7425,7 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
6668
7425
|
}
|
|
6669
7426
|
}
|
|
6670
7427
|
),
|
|
6671
|
-
/* @__PURE__ */
|
|
7428
|
+
/* @__PURE__ */ jsx43(Button19, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
|
|
6672
7429
|
] })
|
|
6673
7430
|
] });
|
|
6674
7431
|
}
|