@oondemand/oon-core-front 0.4.26 → 0.4.28

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 CHANGED
@@ -5364,7 +5364,8 @@ import { Box as Box24, Button as Button17, Flex as Flex17, Spacer as Spacer2, Te
5364
5364
  import { Outlet, useNavigate as useNavigate2 } from "react-router-dom";
5365
5365
 
5366
5366
  // src/shell/Sidebar.tsx
5367
- import { Box as Box23, Flex as Flex16, Image, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
5367
+ import { Box as Box23, Flex as Flex16, Image, Spinner as Spinner4, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
5368
+ import { useState as useState19 } from "react";
5368
5369
  import { NavLink } from "react-router-dom";
5369
5370
  import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
5370
5371
  function groupBySection(items) {
@@ -5376,6 +5377,80 @@ function groupBySection(items) {
5376
5377
  }
5377
5378
  return Array.from(groups.entries());
5378
5379
  }
5380
+ function launchAppCode(action) {
5381
+ const match = /^launch-app:([a-z][a-z0-9-]{2,62})$/.exec(String(action || ""));
5382
+ return match?.[1] || "";
5383
+ }
5384
+ function errorMessage2(error) {
5385
+ const value3 = error;
5386
+ return value3?.response?.data?.error?.message || value3?.response?.data?.message || value3?.message || "N\xE3o foi poss\xEDvel abrir o App.";
5387
+ }
5388
+ function PlatformAppMenuItem({ item, appCode }) {
5389
+ const { http } = useOonApi();
5390
+ const [opening, setOpening] = useState19(false);
5391
+ const [launchError, setLaunchError] = useState19("");
5392
+ async function launch() {
5393
+ if (opening) return;
5394
+ const popup = window.open("about:blank", "_blank");
5395
+ if (!popup) {
5396
+ setLaunchError("Permita pop-ups para abrir o App em uma nova aba.");
5397
+ return;
5398
+ }
5399
+ popup.opener = null;
5400
+ setOpening(true);
5401
+ setLaunchError("");
5402
+ try {
5403
+ const home = (await http.get("/portal/home")).data;
5404
+ const target = home.platformApps.find((candidate) => candidate.app.codigo === appCode);
5405
+ if (!target || target.action !== "open") {
5406
+ throw new Error(`${target?.app.nome || item.label} ainda n\xE3o est\xE1 dispon\xEDvel.`);
5407
+ }
5408
+ const response = await http.post("/portal/launch", {
5409
+ appCode,
5410
+ environment: target.deployment.environment
5411
+ });
5412
+ if (!response.data.openUrl) {
5413
+ throw new Error("A autoriza\xE7\xE3o de abertura n\xE3o retornou uma URL.");
5414
+ }
5415
+ popup.location.replace(response.data.openUrl);
5416
+ } catch (error) {
5417
+ popup.close();
5418
+ setLaunchError(errorMessage2(error));
5419
+ } finally {
5420
+ setOpening(false);
5421
+ }
5422
+ }
5423
+ return /* @__PURE__ */ jsxs24(Box23, { width: "100%", children: [
5424
+ /* @__PURE__ */ jsxs24(
5425
+ Flex16,
5426
+ {
5427
+ as: "button",
5428
+ width: "100%",
5429
+ align: "center",
5430
+ justify: { base: "center", lg: "flex-start" },
5431
+ gap: 3,
5432
+ px: { base: 2, lg: 3 },
5433
+ py: "10px",
5434
+ borderRadius: "9px",
5435
+ fontSize: "13px",
5436
+ fontWeight: "500",
5437
+ color: "#46545C",
5438
+ cursor: opening ? "wait" : "pointer",
5439
+ "aria-disabled": opening,
5440
+ pointerEvents: opening ? "none" : "auto",
5441
+ title: item.label,
5442
+ "aria-label": `Abrir ${item.label} em uma nova aba`,
5443
+ onClick: () => void launch(),
5444
+ _hover: { bg: "#F8F9FA", color: "brand.700" },
5445
+ children: [
5446
+ opening ? /* @__PURE__ */ jsx33(Spinner4, { size: "xs" }) : /* @__PURE__ */ jsx33(Box23, { w: "7px", h: "7px", borderRadius: "full", bg: "gray.300" }),
5447
+ /* @__PURE__ */ jsx33(Text24, { display: { base: "none", lg: "block" }, lineClamp: 1, children: item.label })
5448
+ ]
5449
+ }
5450
+ ),
5451
+ launchError ? /* @__PURE__ */ jsx33(Text24, { role: "alert", px: 3, py: 1, fontSize: "10px", color: "red.600", children: launchError }) : null
5452
+ ] });
5453
+ }
5379
5454
  function Sidebar({ app, menu, registry }) {
5380
5455
  const { hasPermission } = useOonAuth();
5381
5456
  const visible = menu.filter((item) => !item.hidden && hasPermission(item.permissions));
@@ -5435,6 +5510,8 @@ function Sidebar({ app, menu, registry }) {
5435
5510
  items.map((item) => {
5436
5511
  const CustomMenuItem = resolveComponent(registry, item.renderer, "menuRenderers");
5437
5512
  if (CustomMenuItem) return /* @__PURE__ */ jsx33(CustomMenuItem, { item }, item.href);
5513
+ const appCode = launchAppCode(item.action);
5514
+ if (appCode) return /* @__PURE__ */ jsx33(PlatformAppMenuItem, { item, appCode }, item.href);
5438
5515
  return /* @__PURE__ */ jsx33(NavLink, { to: item.href, end: item.href === "/", title: item.label, children: ({ isActive }) => /* @__PURE__ */ jsxs24(
5439
5516
  Flex16,
5440
5517
  {
@@ -5468,7 +5545,7 @@ function Sidebar({ app, menu, registry }) {
5468
5545
  // package.json
5469
5546
  var package_default = {
5470
5547
  name: "@oondemand/oon-core-front",
5471
- version: "0.4.26",
5548
+ version: "0.4.28",
5472
5549
  repository: {
5473
5550
  type: "git",
5474
5551
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -5923,7 +6000,7 @@ function AppAccessGuard({ children }) {
5923
6000
  }
5924
6001
 
5925
6002
  // src/security/LoginPage.tsx
5926
- import { useState as useState19 } from "react";
6003
+ import { useState as useState20 } from "react";
5927
6004
  import { Box as Box26, Button as Button19, Flex as Flex19, Heading as Heading15, Input as Input11, SimpleGrid as SimpleGrid6, Text as Text27, VStack as VStack5 } from "@chakra-ui/react";
5928
6005
  import { Link as Link3, Navigate as Navigate2, useLocation as useLocation4 } from "react-router-dom";
5929
6006
  import { jsx as jsx38, jsxs as jsxs27 } from "react/jsx-runtime";
@@ -5954,13 +6031,13 @@ function tenantUrl(path, tenantId) {
5954
6031
  function LoginPage({ app, onboardingEnabled = false }) {
5955
6032
  const { status, login } = useOonAuth();
5956
6033
  const location = useLocation4();
5957
- const [email, setEmail] = useState19("");
5958
- const [password, setPassword] = useState19("");
5959
- const [submitting, setSubmitting] = useState19(false);
5960
- const [message, setMessage] = useState19(null);
5961
- const [tenants, setTenants] = useState19([]);
5962
- const [selectorMode, setSelectorMode] = useState19(false);
5963
- const [openingTenant, setOpeningTenant] = useState19(null);
6034
+ const [email, setEmail] = useState20("");
6035
+ const [password, setPassword] = useState20("");
6036
+ const [submitting, setSubmitting] = useState20(false);
6037
+ const [message, setMessage] = useState20(null);
6038
+ const [tenants, setTenants] = useState20([]);
6039
+ const [selectorMode, setSelectorMode] = useState20(false);
6040
+ const [openingTenant, setOpeningTenant] = useState20(null);
5964
6041
  const redirect = safeRedirect(location.search);
5965
6042
  if (status === "authenticated" && !selectorMode) return /* @__PURE__ */ jsx38(Navigate2, { to: redirect, replace: true });
5966
6043
  if (status === "forbidden") return /* @__PURE__ */ jsx38(Navigate2, { to: "/acesso-negado", replace: true });
@@ -6048,16 +6125,16 @@ function LoginPage({ app, onboardingEnabled = false }) {
6048
6125
  }
6049
6126
 
6050
6127
  // src/security/FirstAccessPage.tsx
6051
- import { useState as useState20 } from "react";
6128
+ import { useState as useState21 } from "react";
6052
6129
  import { Box as Box27, Button as Button20, Flex as Flex20, Heading as Heading16, Input as Input12, Text as Text28, VStack as VStack6 } from "@chakra-ui/react";
6053
6130
  import { Navigate as Navigate3 } from "react-router-dom";
6054
6131
  import { jsx as jsx39, jsxs as jsxs28 } from "react/jsx-runtime";
6055
6132
  function FirstAccessPage() {
6056
6133
  const { status, completeFirstAccess } = useOonAuth();
6057
- const [password, setPassword] = useState20("");
6058
- const [confirm, setConfirm] = useState20("");
6059
- const [submitting, setSubmitting] = useState20(false);
6060
- const [message, setMessage] = useState20(null);
6134
+ const [password, setPassword] = useState21("");
6135
+ const [confirm, setConfirm] = useState21("");
6136
+ const [submitting, setSubmitting] = useState21(false);
6137
+ const [message, setMessage] = useState21(null);
6061
6138
  if (status === "authenticated") return /* @__PURE__ */ jsx39(Navigate3, { to: "/", replace: true });
6062
6139
  if (status === "unauthenticated") return /* @__PURE__ */ jsx39(Navigate3, { to: "/login", replace: true });
6063
6140
  if (status === "forbidden") return /* @__PURE__ */ jsx39(Navigate3, { to: "/acesso-negado", replace: true });
@@ -6101,7 +6178,7 @@ function FirstAccessPage() {
6101
6178
  }
6102
6179
 
6103
6180
  // src/security/ActivationPage.tsx
6104
- import { useEffect as useEffect11, useState as useState21 } from "react";
6181
+ import { useEffect as useEffect11, useState as useState22 } from "react";
6105
6182
  import { Box as Box28, Button as Button21, Heading as Heading17, Input as Input13, Text as Text29, VStack as VStack7 } from "@chakra-ui/react";
6106
6183
  import { Fragment as Fragment6, jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
6107
6184
  function encodeBasicCredentials2(email, password) {
@@ -6113,21 +6190,21 @@ function encodeBasicCredentials2(email, password) {
6113
6190
  function ActivationPage() {
6114
6191
  const { http } = useOonApi();
6115
6192
  const activation = useActivation();
6116
- const [step, setStep] = useState21(1);
6117
- const [config, setConfig] = useState21(null);
6118
- const [code, setCode] = useState21("");
6119
- const [preview, setPreview] = useState21(null);
6120
- const [global, setGlobal] = useState21({});
6121
- const [app, setApp] = useState21({});
6122
- const [rootEmail, setRootEmail] = useState21("");
6123
- const [rootPassword, setRootPassword] = useState21("");
6124
- const [devName, setDevName] = useState21("");
6125
- const [devEmail, setDevEmail] = useState21("");
6126
- const [devPassword, setDevPassword] = useState21("");
6127
- const [showCodeFlow, setShowCodeFlow] = useState21(false);
6128
- const [devResult, setDevResult] = useState21(null);
6129
- const [error, setError] = useState21(null);
6130
- const [submitting, setSubmitting] = useState21(false);
6193
+ const [step, setStep] = useState22(1);
6194
+ const [config, setConfig] = useState22(null);
6195
+ const [code, setCode] = useState22("");
6196
+ const [preview, setPreview] = useState22(null);
6197
+ const [global, setGlobal] = useState22({});
6198
+ const [app, setApp] = useState22({});
6199
+ const [rootEmail, setRootEmail] = useState22("");
6200
+ const [rootPassword, setRootPassword] = useState22("");
6201
+ const [devName, setDevName] = useState22("");
6202
+ const [devEmail, setDevEmail] = useState22("");
6203
+ const [devPassword, setDevPassword] = useState22("");
6204
+ const [showCodeFlow, setShowCodeFlow] = useState22(false);
6205
+ const [devResult, setDevResult] = useState22(null);
6206
+ const [error, setError] = useState22(null);
6207
+ const [submitting, setSubmitting] = useState22(false);
6131
6208
  useEffect11(() => {
6132
6209
  http.get("/ativacao/configuracao").then((response) => {
6133
6210
  setConfig(response.data);
@@ -6900,7 +6977,7 @@ function startFromManifest(manifest, runtime) {
6900
6977
  import { Stack as Stack16 } from "@chakra-ui/react";
6901
6978
 
6902
6979
  // src/components/CoreIntegration.tsx
6903
- import { useEffect as useEffect12, useState as useState22 } from "react";
6980
+ import { useEffect as useEffect12, useState as useState23 } from "react";
6904
6981
  import { Badge as Badge6, Box as Box29, Button as Button22, Flex as Flex21, Heading as Heading18, Input as Input14, Stack as Stack11, Text as Text30 } from "@chakra-ui/react";
6905
6982
  import { useMutation as useMutation6, useQuery as useQuery12 } from "@tanstack/react-query";
6906
6983
  import { jsx as jsx46, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -7065,7 +7142,7 @@ function ExecutionDetails({ execution }) {
7065
7142
  }
7066
7143
  function ProviderConfigurationPanel({ provider }) {
7067
7144
  const { http } = useOonApi();
7068
- const [draft, setDraft] = useState22({
7145
+ const [draft, setDraft] = useState23({
7069
7146
  instanceId: "default",
7070
7147
  label: provider.label,
7071
7148
  active: true,
@@ -7292,7 +7369,7 @@ function ProviderConfigurationPanel({ provider }) {
7292
7369
  }
7293
7370
  function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
7294
7371
  const { http } = useOonApi();
7295
- const [expandedExecutionId, setExpandedExecutionId] = useState22(null);
7372
+ const [expandedExecutionId, setExpandedExecutionId] = useState23(null);
7296
7373
  const providers = useQuery12({
7297
7374
  queryKey: ["core-integrations", "health"],
7298
7375
  queryFn: async () => (await http.get("/integrations/health")).data?.results ?? []
@@ -7551,7 +7628,7 @@ function CoreIntegrationMappings() {
7551
7628
  }
7552
7629
 
7553
7630
  // src/components/CoreIntegrationTickets.tsx
7554
- import { useEffect as useEffect13, useMemo as useMemo12, useState as useState23 } from "react";
7631
+ import { useEffect as useEffect13, useMemo as useMemo12, useState as useState24 } from "react";
7555
7632
  import { Badge as Badge8, Box as Box31, Button as Button23, Flex as Flex23, Heading as Heading20, Input as Input15, Stack as Stack13, Text as Text32 } from "@chakra-ui/react";
7556
7633
  import { useMutation as useMutation7, useQuery as useQuery14 } from "@tanstack/react-query";
7557
7634
  import { jsx as jsx48, jsxs as jsxs32 } from "react/jsx-runtime";
@@ -7777,12 +7854,12 @@ function TicketCard({
7777
7854
  }
7778
7855
  function CoreIntegrationTickets({ provider = "omie" }) {
7779
7856
  const { http } = useOonApi();
7780
- const [view, setView] = useState23("list");
7781
- const [status, setStatus] = useState23("");
7782
- const [searchInput, setSearchInput] = useState23("");
7783
- const [search, setSearch] = useState23("");
7784
- const [page, setPage] = useState23(1);
7785
- const [expandedId, setExpandedId] = useState23(null);
7857
+ const [view, setView] = useState24("list");
7858
+ const [status, setStatus] = useState24("");
7859
+ const [searchInput, setSearchInput] = useState24("");
7860
+ const [search, setSearch] = useState24("");
7861
+ const [page, setPage] = useState24(1);
7862
+ const [expandedId, setExpandedId] = useState24(null);
7786
7863
  const limit = view === "board" ? 200 : 25;
7787
7864
  useEffect13(() => {
7788
7865
  const timeout = window.setTimeout(() => {
@@ -8043,11 +8120,11 @@ function CoreIntegrationTickets({ provider = "omie" }) {
8043
8120
  }
8044
8121
 
8045
8122
  // src/components/CoreOmieIntegrationWorkspace.tsx
8046
- import { useState as useState25 } from "react";
8123
+ import { useState as useState26 } from "react";
8047
8124
  import { Button as Button25, Flex as Flex25, Stack as Stack15 } from "@chakra-ui/react";
8048
8125
 
8049
8126
  // src/components/CoreOmieIntegration.tsx
8050
- import { useEffect as useEffect14, useState as useState24 } from "react";
8127
+ import { useEffect as useEffect14, useState as useState25 } from "react";
8051
8128
  import { Badge as Badge9, Box as Box32, Button as Button24, Flex as Flex24, Heading as Heading21, Input as Input16, Stack as Stack14, Text as Text33 } from "@chakra-ui/react";
8052
8129
  import { useMutation as useMutation8, useQuery as useQuery15 } from "@tanstack/react-query";
8053
8130
  import { jsx as jsx49, jsxs as jsxs33 } from "react/jsx-runtime";
@@ -8119,7 +8196,7 @@ function OmieConfigurationTab() {
8119
8196
  queryKey: ["core-omie", "configuration"],
8120
8197
  queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
8121
8198
  });
8122
- const [draft, setDraft] = useState24({
8199
+ const [draft, setDraft] = useState25({
8123
8200
  instanceId: "default",
8124
8201
  label: "Omie",
8125
8202
  active: true,
@@ -8436,8 +8513,8 @@ function OmieSynchronizationTab() {
8436
8513
  }
8437
8514
  function OmieWebhooksTab() {
8438
8515
  const { http } = useOonApi();
8439
- const [instanceId, setInstanceId] = useState24("default");
8440
- const [copied, setCopied] = useState24(false);
8516
+ const [instanceId, setInstanceId] = useState25("default");
8517
+ const [copied, setCopied] = useState25(false);
8441
8518
  const configuration = useQuery15({
8442
8519
  queryKey: ["core-omie", "configuration"],
8443
8520
  queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
@@ -8571,7 +8648,7 @@ function diagnosticMessage3(value3) {
8571
8648
  }
8572
8649
  function OmieHistoryTab() {
8573
8650
  const { http } = useOonApi();
8574
- const [expandedId, setExpandedId] = useState24(null);
8651
+ const [expandedId, setExpandedId] = useState25(null);
8575
8652
  const history = useQuery15({
8576
8653
  queryKey: ["core-omie", "history"],
8577
8654
  queryFn: async () => (await http.get("/integrations/history", {
@@ -8694,7 +8771,7 @@ var TABS = [
8694
8771
  { id: "history", label: "Hist\xF3rico" }
8695
8772
  ];
8696
8773
  function CoreOmieIntegration() {
8697
- const [tab, setTab] = useState24("configuration");
8774
+ const [tab, setTab] = useState25("configuration");
8698
8775
  return /* @__PURE__ */ jsxs33(Stack14, { gap: 5, children: [
8699
8776
  /* @__PURE__ */ jsxs33(Box32, { children: [
8700
8777
  /* @__PURE__ */ jsx49(Heading21, { size: "lg", children: "Integra\xE7\xE3o Omie" }),
@@ -8720,7 +8797,7 @@ function CoreOmieIntegration() {
8720
8797
  // src/components/CoreOmieIntegrationWorkspace.tsx
8721
8798
  import { jsx as jsx50, jsxs as jsxs34 } from "react/jsx-runtime";
8722
8799
  function CoreOmieIntegrationWorkspace() {
8723
- const [view, setView] = useState25("integration");
8800
+ const [view, setView] = useState26("integration");
8724
8801
  return /* @__PURE__ */ jsxs34(Stack15, { gap: 4, children: [
8725
8802
  /* @__PURE__ */ jsxs34(Flex25, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: [
8726
8803
  /* @__PURE__ */ jsx50(
@@ -8848,14 +8925,14 @@ function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/mo
8848
8925
  }
8849
8926
 
8850
8927
  // src/components/CoreAssistant.tsx
8851
- import { useState as useState26 } from "react";
8928
+ import { useState as useState27 } from "react";
8852
8929
  import { Box as Box33, Button as Button27, Flex as Flex27, Heading as Heading23, Input as Input17, Stack as Stack18, Text as Text35 } from "@chakra-ui/react";
8853
8930
  import { useMutation as useMutation10 } from "@tanstack/react-query";
8854
8931
  import { jsx as jsx53, jsxs as jsxs37 } from "react/jsx-runtime";
8855
8932
  function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint = "/assistant-runs" }) {
8856
8933
  const { http } = useOonApi();
8857
- const [messages, setMessages] = useState26([]);
8858
- const [input, setInput] = useState26("");
8934
+ const [messages, setMessages] = useState27([]);
8935
+ const [input, setInput] = useState27("");
8859
8936
  const ask = useMutation10({
8860
8937
  mutationFn: async (message) => {
8861
8938
  const { data } = await http.post(